You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cookbook manifest GET below API v2 should drop files outside the classic segments, as erchef does #297
A cookbook version (or cookbook artifact) GET answered below server API version 2 should drop every file outside the nine classic segments, as erchef does. cinc-server-ng keeps those files instead, so a client that fetches manifests at API v1 looks complete against cinc-server-ng and silently loses files against a real Chef Server.
What erchef does
From API v2 a manifest GET returns all_files. Below v2, erchef rebuilds the nine segments from the stored all_files and drops any file whose directory is not one of them: ohai/, compliance/, spec/, and so on.
chef_cookbook_version:populate_segments. The code comment says: "We silently drop files that land in segments not listed in ?COOKBOOK_SEGMENTS".
wants_all_files(0|1) -> false in the same module.
Cookbook artifacts take the same path through oc_chef_cookbook_artifact_version.
What cinc-server-ng does
toSegments (internal/api/cookbook_segments.go) files a non-segment file under root_files with its full path as the name (the !isCookbookSegment(segment) branch). It is not dropped.
At v2 the two servers agree: both return all_files with every file.
Why it matters
cinc-api fetched manifests at API v1, so Cookbooks.Download wrote cookbooks missing their ohai/ and compliance/ files against erchef, with no error. Its integration suite runs against cinc-server-ng and could not catch this, because every file came back. The client now fetches at v2 (cinc-project/cinc-api#149). A cinc-server-ng that matched erchef below v2 would have exposed the bug, and would catch a regression.
Repro
Upload a cookbook through the API v2 sandbox flow, with all_files including ohai/plugins/x.rb.
GET /organizations/ORG/cookbooks/NAME/VERSION with X-Ops-Server-API-Version: 1.
erchef: ohai/plugins/x.rb appears in no segment. cinc-server-ng: it appears in root_files.
Suggested fix
In toSegments, skip any entry whose first path component is not a cookbook segment, instead of moving it to root_files. Files at the cookbook root (no /) still belong in root_files.
Activity
fix(api): drop non-segment files from cookbook manifests below API v2 (…