Skip to content

Cookbook manifest GET below API v2 should drop files outside the classic segments, as erchef does #297

Done

Description

@tas50

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

  1. Upload a cookbook through the API v2 sandbox flow, with all_files including ohai/plugins/x.rb.
  2. GET /organizations/ORG/cookbooks/NAME/VERSION with X-Ops-Server-API-Version: 1.
  3. 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

  1. added a commit that references this issue on Dec 2, 2026
    571b5de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions