pipecd icon indicating copy to clipboard operation
pipecd copied to clipboard

pipectl migrate application-config panics on malformed application configuration

Open CodeWith-sakib opened this issue 5 months ago • 1 comments

What happened

pipectl migrate application-config panics when the input application configuration is malformed instead of returning a descriptive validation error.

The panic occurs when the input configuration is missing required fields such as spec. Instead of reporting an invalid configuration, the command terminates with a Go panic:

panic: interface conversion: interface {} is nil, not map[string]interface {}

The panic originates from:

pkg/app/pipectl/cmd/migrate/application_config.go:142

What you expected to happen

The command should validate the input application configuration and return a descriptive error (for example, indicating that the required spec field is missing or invalid) instead of panicking.


How to reproduce it

  1. Create a file named bad.yaml with the following content:
kind: KUBERNETES
  1. Run the migration command:
go run ./cmd/pipectl migrate application-config --config-files bad.yaml
  1. Observe that the command panics with:
panic: interface conversion: interface {} is nil, not map[string]interface {}

Stack trace (truncated):

panic: interface conversion: interface {} is nil, not map[string]interface {}

github.com/pipe-cd/pipecd/pkg/app/pipectl/cmd/migrate.(*applicationConfig).migrateApplicationConfig(...)
    pkg/app/pipectl/cmd/migrate/application_config.go:142

Environment

  • piped version: N/A (issue reproduced using pipectl)
  • control-plane version: N/A
  • Others:
    • PipeCD branch: master
    • Commit: 5b81c813b
    • Go version: go1.26.2
    • OS: macOS (Apple Silicon)

Additional context

From the investigation, the panic is caused by unchecked type assertions while reading the parsed YAML (for example, assuming the spec field is always present and has the expected type). Returning a validation error instead of panicking would make the migration command more robust when handling malformed input.

If this behavior is considered a bug, I'd be happy to work on a fix and submit a PR.

CodeWith-sakib avatar Jul 05 '26 11:07 CodeWith-sakib

I'd be happy to work on a fix for this issue and submit a PR if the proposed behavior sounds good.

CodeWith-sakib avatar Jul 05 '26 11:07 CodeWith-sakib