{"record":{"id":"78559b4fb4326a6b","repo":"hashicorp/packer","slug":"unsupported-scope-s-supported-squashed-all-la","errorCode":null,"errorMessage":"unsupported scope: %s (supported: squashed, all-layers)","messagePattern":"unsupported scope: (.+?) \\(supported: squashed, all-layers\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sbom/generator.go","lineNumber":75,"sourceCode":"\t\treturn FormatCycloneDX, nil\n\t}\n\tif strings.Contains(formatArg, \"spdx\") {\n\t\treturn FormatSPDX, nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"unsupported format: %s\", formatArg)\n}\n\nfunc ParseScopeFromArgs(scopeArg string) (string, error) {\n\tscopeArg = strings.ToLower(strings.TrimSpace(scopeArg))\n\n\tswitch scopeArg {\n\tcase ScopeSquashed:\n\t\treturn ScopeSquashed, nil\n\tcase ScopeAllLayers, \"all\", \"alllayers\":\n\t\treturn ScopeAllLayers, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported scope: %s (supported: squashed, all-layers)\", scopeArg)\n\t}\n}\n","sourceCodeStart":57,"sourceCodeEnd":78,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/sbom/generator.go#L57-L78","documentation":"ParseScopeFromArgs accepts only 'squashed', 'all-layers', plus aliases 'all' and 'alllayers' (after lowercasing/trimming). Anything else returns `unsupported scope: %s (supported: squashed, all-layers)`. Scope controls whether Syft catalogs the merged image filesystem or every layer.","triggerScenarios":"Calling ParseScopeFromArgs(\"all layers\"), (\"squashed-layers\"), (\"directory\"), or empty-but-set odd values like \"squashed \" trimmed fine, but \"SquashedLayers\" fails.","commonSituations":"Copying scope flags from other tools (trivy/grype use different names); typos like \"all-layerss\"; expecting syft's multi-value scope syntax; blank config strings from env vars that bypass NewGenerator defaults.","solutions":["Pass exactly \"squashed\" or \"all-layers\" (aliases \"all\" and \"alllayers\" also work)","Rely on the empty-string default: NewGenerator sets ScopeSquashed when Scope is empty","Read the error's supported list and correct the spelling/hyphenation","Validate scope at config-parse time rather than at generate time"],"exampleFix":"// before\nscope, err := sbom.ParseScopeFromArgs(\"all layers\")\n// after\nscope, err := sbom.ParseScopeFromArgs(\"all-layers\")","handlingStrategy":"validation","validationCode":"scope, err := sbom.ParseScopeFromArgs(scopeArg)\nif err != nil {\n    return fmt.Errorf(\"invalid SBOM scope %q: %w\", scopeArg, err)\n}","typeGuard":"func isSupportedScope(s string) bool {\n    switch strings.ToLower(strings.TrimSpace(s)) {\n    case \"squashed\", \"all-layers\", \"all\", \"alllayers\", \"\": return true\n    }\n    return false\n}","tryCatchPattern":"scope, err := sbom.ParseScopeFromArgs(arg)\nif err != nil {\n    return fmt.Errorf(\"scope must be squashed or all-layers: %w\", err)\n}","preventionTips":["Validate scope strings at config parse time","Leave Scope empty to inherit the squashed default","Do not copy scope names from trivy/grype; they differ"],"tags":["go","validation","config","sbom"],"backgroundTag":"unsupported-scope","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}