devcontainer.json $schema URL downgrade and unknown field handling in GitHub Codespaces
0 reputation · 23 Nov 2023, 01:59 UTC
0 reputation · 23 Nov 2023, 01:59 UTC
Determine whether GitHub Codespaces should automatically strip or ignore unknown devcontainer.json fields when the $schema URL is downgraded to an older version, or whether it should reject the workspace and require manual adjustment.
It is unclear whether the documentation provides an automated safe‑rollback mechanism for downgrading the $schema field, and the current behavior leaves unknown fields such as postCreateCommand active after a downgrade, potentially causing an inconsistent environment.
31275 reputation · 23 Nov 2023, 09:37 UTC
GitHub Codespaces does not automatically strip or ignore unknown fields when you downgrade the $schema URL. It also does not reject the workspace startup or prompt for manual adjustment. Instead, the platform retains all fields present in devcontainer.json and validates only against the schema version you explicitly reference. Fields that exist in the newer schema but not the older one (such as postCreateCommand in certain versions) remain in the configuration but may be ignored, misinterpreted, or produce silent inconsistencies because the older schema does not define them.
$schema URL selects a specific JSON Schema draft. Codespaces uses that schema to validate the file, but the devcontainer schema historically sets additionalProperties: true (or omits the keyword), so unknown properties pass validation.devcontainer.json when you change the schema URL. The onus is on the author to align the configuration with the targeted version.The devcontainer specification evolves by adding fields. When you point $schema to an older URL, you are effectively saying “validate this file as if it were written for version X.” The validator honors that request: it checks required fields and types defined in version X, but it does not delete keys that version X doesn’t know about. Those keys travel forward into the container runtime, where the Codespaces agent may ignore them, treat them differently, or—if the runtime is newer than the schema—still execute them. This mismatch is the source of the “inconsistent environment” risk you identified.
$schema to the older URL you intend to use (e.g., https://aka.ms/devcontainer-json/schema.json for a specific release)."__testUnknown": true.~/.codespaces/logs/ in the container). Look for lines containing unknown, unrecognized, or validation.Treat $schema as a contract, not a migration tool. When you must target an older schema:
Which exact $schema URL (including version fragment, if any) are you downgrading from and to? The set of recognized fields differs per release, and knowing the pair lets me confirm whether postCreateCommand or other specific keys are defined in the target version.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.