goharbor/harbor · error · lib/errors.Error
BAD_REQUEST
BAD_REQUEST
Error message
addition %s isn't supported for %s
What it means
The CNAI processor maps addition requests to parsers: readme, license, and files are handled; anything else falls to the default branch and returns BadRequest 'addition %s isn't supported for CNAI'.
Source
Thrown at src/controller/artifact/processor/cnai/cnai.go:70
return
}
}
type processor struct {
*base.ManifestProcessor
}
func (p *processor) AbstractAddition(ctx context.Context, artifact *artifact.Artifact, addition string) (*ps.Addition, error) {
var additionParser parser.Parser
switch addition {
case AdditionTypeReadme:
additionParser = parser.NewReadme(p.RegCli)
case AdditionTypeLicense:
additionParser = parser.NewLicense(p.RegCli)
case AdditionTypeFiles:
additionParser = parser.NewFiles(p.RegCli)
default:
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
WithMessagef("addition %s isn't supported for %s", addition, ArtifactTypeCNAI)
}
mf, _, err := p.RegCli.PullManifest(artifact.RepositoryName, artifact.Digest)
if err != nil {
return nil, err
}
_, payload, err := mf.Payload()
if err != nil {
return nil, err
}
manifest := &ocispec.Manifest{}
if err := json.Unmarshal(payload, manifest); err != nil {
return nil, err
}
View on GitHub (pinned to 7b2fd08cc5)
Solutions
- Request only readme, license, or files additions for CNAI artifacts
- Gate the request on the artifact type reported by the API
- Keep a per-type allowlist of additions in the client instead of a single hardcoded addition name
Defensive patterns
Strategy: type-guard
Type guard
var cnaiAdditions = map[string]bool{"readme": true, "license": true, "files": true}
func cnaiAdditionSupported(addition string) bool {
return cnaiAdditions[addition]
} Try / catch
if _, err := p.AbstractAddition(ctx, art, addition); err != nil {
if errors.IsErr(err, errors.BadRequestCode) && strings.Contains(err.Error(), "CNAI") {
// addition outside {readme, license, files}: skip
}
} Prevention
- Use only readme, license, files for CNAI artifacts
- Do not reuse chart (values) or image (build_history) addition names on AI artifacts
- Maintain per-type addition allowlists in client code
When it happens
Trigger: GET .../artifacts/{ref}/additions/{x} on a CNAI artifact with x not in {readme, license, files} — e.g. values (chart-style) or build_history (image-style).
Common situations: Clients reusing chart or image addition vocabularies against AI artifacts; uniform addition probing across mixed repositories.
Related errors
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/14a91921f21b2801.
Report an issue: GitHub.