fix(policies): evaluate a non-JSON ARTIFACT material instead of failing
Fixes PFM-8294.
chainloop att add failed with failed to parse input when a policy was attached to an ARTIFACT material with non-JSON content, such as a ZIP file. It failed even with gate: false, and the material was not added. Before evaluating policies, the CLI decoded every material's content as JSON, and ARTIFACT has no conversion step. A policy with no kind, such as upstream-check, applies to any material and reads only chainloop_metadata, so the file's content never mattered to it.
With this change:
- An
ARTIFACTwhose content does not decode as JSON is evaluated as an empty object pluschainloop_metadata. It does not fail. - An
ARTIFACTwith JSON content behaves as before, including the existing rule that only the first JSON value is read. - Typed materials (SBOM, SARIF, and so on) still fail when their content does not match their format.
Trade-off: a policy that reads the content of a non-JSON ARTIFACT now sees an empty object. A policy with a valid_input rule reports it as skipped; one without can pass with no message. This includes a damaged JSON file, which used to fail the material. Before this change, a content-reading policy on a binary or text ARTIFACT could never run.
The choice is recorded as ATT-005 on the Attestation Process Current Decisions page (docs/decisions/attestation-process.md).
This PR was written with the help of Claude Code.
š¤ Posted by Maximus bot (Claude Code) on behalf of @migmartri