Skip to content

CLI over-validates --config / --override-config filenames #65

@pofallon

Description

@pofallon

Summary

Deacon rejects any --config or --override-config path whose filename isn't one of devcontainer.json, .devcontainer.json, devcontainer.jsonc, or .devcontainer.jsonc. The upstream reference CLI (@devcontainers/cli) accepts any path string and doesn't enforce filename allow-lists, so this is a deacon-specific divergence from spec parity.

Reproduction

$ deacon read-configuration --workspace-folder . --config ./alpha.json
Error: Invalid --config filename: 'alpha.json'. Filename must be one of: devcontainer.json, .devcontainer.json, devcontainer.jsonc, or .devcontainer.jsonc.

$ deacon up --workspace-folder . --override-config ./override.foo.json
Error: Invalid --override-config filename: 'override.foo.json'. Filename must be one of: ...

Upstream behavior

devcontainers/cli's devContainersSpecCLI.ts defines both flags as plain optional strings:

'config':          { type: 'string', description: 'devcontainer.json path...' }
'override-config': { type: 'string', description: 'devcontainer.json path...' }

The resolver just does URI.file(path.resolve(process.cwd(), config)) — no filename validation. The description string mentions the typical filename for documentation; it isn't a gate.

Spec position

The containers.dev / devcontainers/spec discovery rules (.devcontainer/devcontainer.json, .devcontainer.json, named-subdir variants) govern implicit discovery on the workspace. They do not constrain an explicit CLI path argument.

Impact on examples

Surfaced while drafting examples/ for spec coverage (see #TBD). Several scenarios that naturally want compact alternate filenames (override.onCreate.json, gpu-true.json, alpha.json for a cycle test) had to be restructured into one-deep subdirectories purely to satisfy this validator. Restoring the original layout once this lands.

Proposed fix

Drop the filename allow-list, or downgrade it to a warning. The validator costs more in spec-parity than it buys in user safety — a misspelled filename will already produce a "file not found" error from the resolver.

Acceptance

  • deacon read-configuration --config ./any-filename.json returns the parsed configuration (or "file not found" if the path doesn't exist) instead of an "Invalid --config filename" error.
  • Same for --override-config on all subcommands that accept it (up, build, read-configuration, run-user-commands, set-up).
  • Existing valid filenames (devcontainer.json, etc.) still work.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions