Skip to content

API /v1/bundle?dynamic=... error surfaces CLI-flag phrasing ("--dynamic flag") #680

Description

@lockwobr

Bug Description

When POST /v1/bundle?dynamic=<key>:<path> names a component key that
isn't in the registry, the returned error message contains CLI-centric
phrasing ("in --dynamic flag") surfaced verbatim through the HTTP API.
The same endpoint's malformed-input case correctly wraps with
"Invalid dynamic parameter" — this is an inconsistency within a single
endpoint's own error surface.

Impact

Low — cosmetic/API-UX. Misleading for API consumers who have never used
the CLI.

Component

API server (aicrd) + bundler core

Regression?

Unknown.

Steps to Reproduce

make server &

# any valid recipe body
curl -s -X POST 'http://localhost:8080/v1/bundle?dynamic=nonexistent-component:foo.bar' \
  -H 'Content-Type: application/json' \
  --data-binary @/tmp/good-recipe.json

Expected Behavior

Layer-neutral message, e.g.:

{
  "code": "INVALID_REQUEST",
  "message": "unknown component \"nonexistent-component\" in dynamic declaration: not found in component registry"
}

Same text whether the error is raised from the CLI --dynamic flag or
the API ?dynamic= query parameter.

Actual Behavior

{
  "code": "INVALID_REQUEST",
  "message": "unknown component \"nonexistent-component\" in --dynamic flag: not found in component registry"
}

Root Cause

pkg/bundler/bundler.go:957 constructs the error with CLI-specific
phrasing in the bundler-core layer (buildDynamicValuesMap):

return nil, errors.New(errors.ErrCodeInvalidRequest,
    fmt.Sprintf("unknown component %q in --dynamic flag: not found in component registry", key))

The bundler is a shared dependency of both cmd/aicr and the API server,
so its error text should be layer-neutral.

Proposed Fix

Change the bundler-core error wording to layer-neutral phrasing
(e.g., "in dynamic declaration") so both CLI and API produce the same
non-CLI-centric message. One-string swap. Keep the same
ErrCodeInvalidRequest code.

Environment

  • AICR version: v0.12.0-rc1
  • Install method: build from source
  • Platform: N/A (API server only)

Metadata

Metadata

Assignees

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions