Skip to content

fix: fetch cookbook manifests at server API version 2 - #149

Merged
tas50 merged 2 commits into
mainfrom
fix/cookbook-manifest-v2
Nov 27, 2026
Merged

tas50 merged 2 commits into
mainfrom
fix/cookbook-manifest-v2

Conversation

@tas50

@tas50 tas50 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Cookbooks.Get and CookbookArtifacts.Get fetched the manifest at the client's default API version 1. At v0/v1, erchef rebuilds the nine classic segments from the stored all_files and silently drops any file in another directory: chef_cookbook_version:populate_segments has a comment saying exactly that, and wants_all_files is false below v2. Artifacts behave the same way via oc_chef_cookbook_artifact_version. Download and DownloadFiles therefore wrote cookbooks without their ohai/, compliance/, spec/ and similar files, and returned no error.

Both Gets now ask for v2, as chef-client does by default (DEFAULT_SERVER_API_VERSION = "2"), and receive all_files. Download goes through Cookbooks.Get, so it is fixed too. The segment fields stay on Cookbook for servers that predate v2, and AllFiles() merges both shapes as before.

cinc-server-ng returns every file at v1, which hid this. AGENTS.md now records the difference.

Test plan

  • New unit tests assert X-Ops-Server-API-Version: 2 on both Gets and on Download. All failed before the fix, and the harness verifies each signature at that version.
  • New integration case cookbooks/non-segment-files: a cookbook and an artifact with ohai/ and compliance/ files download byte for byte. It passes on cinc-server-ng either way; the erchef run is what tells.
  • go test ./... -race -count=2, cd integration && go test ./..., golangci-lint in both modules

Cookbooks.Get and CookbookArtifacts.Get fetched the manifest at the
client's default API version 1. erchef answers v0/v1 by rebuilding the
nine classic segments from the stored all_files and silently drops any
file in another directory (chef_cookbook_version:populate_segments;
wants_all_files is false below v2; artifacts the same via
oc_chef_cookbook_artifact_version). Download and DownloadFiles then
wrote a cookbook missing its ohai/, compliance/ and similar files with
no error.

Both Gets now ask for v2, as chef-client does by default, and receive
all_files. Download goes through Cookbooks.Get, so it is covered too.
cinc-server-ng returns every file at v1, which hid this; the new
integration case pins the behaviour and AGENTS.md records the gap.

Signed-off-by: Tim Smith <tsmith84@proton.me>
Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50

tas50 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Filed cinc-project/cinc-server-ng#297: below API v2, cinc-server-ng files non-segment files under root_files, where erchef drops them. That is why the new cookbooks/non-segment-files case passes on cinc-server-ng with or without this fix. It ran against erchef on the kept stack and passes with the fix. v2 itself already matches on both servers. AGENTS.md now links the issue.

@tas50
tas50 merged commit 8b12941 into main Nov 27, 2026
7 checks passed
@tas50
tas50 deleted the fix/cookbook-manifest-v2 branch November 27, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant