Skip to content

fix(share): push HCL configs as resolved, self-contained YAML - #4152

Merged
dgageot merged 1 commit into
docker:mainfrom
dgageot:fix/share-push-hcl-inline
Sep 4, 2026
Merged

fix(share): push HCL configs as resolved, self-contained YAML#4152
dgageot merged 1 commit into
docker:mainfrom
dgageot:fix/share-push-hcl-inline

Conversation

@dgageot

@dgageot dgageot commented Sep 3, 2026

Copy link
Copy Markdown
Member

docker agent share push was broken for any HCL agent: the code tried to sniff the config version by unmarshalling the raw file bytes as YAML, which fails for HCL and produced the error "looking for version in config file". As a result, HCL agents — including those that reference prompts via instruction_file or the file() template function — could not be pushed to OCI registries at all.

The fix detects HCL sources via the newly exported config.IsHCLSource and skips the YAML version sniff for them. For HCL configs the pushed bytes are always serialized from the already-loaded config struct, so instruction_file references and file() calls (including template variables) are inlined into the artifact. The pushed artifact is plain YAML that needs no local directory to be useful. A redundant cfg.Version = cmp.Or(raw.Version, latest.Version) assignment was also removed — config.Load already sets the version correctly, and for HCL it would have clobbered a declared value.

YAML instruction_file inlining was already supported; this closes the same gap for HCL sources. No breaking changes or follow-up work expected.

`share push` sniffed the config version with yaml.Unmarshal on the raw
bytes, so any HCL agent failed with "looking for version in config file".
HCL configs now skip the YAML sniff and are always serialized from the
loaded config, so `instruction_file` and `file()` references are inlined
and a pulled artifact needs no local directory. Export config.IsHCLSource
for reuse and drop the redundant cfg.Version assignment (config.Load
already sets it).

Assisted-By: docker-agent
@dgageot
dgageot requested a review from a team as a code owner September 3, 2026 17:27
@aheritier aheritier added area/config For configuration parsing, YAML, environment variables kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Sep 3, 2026
@dgageot
dgageot merged commit d1d0bc4 into docker:main Sep 4, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config For configuration parsing, YAML, environment variables kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants