{"record":{"id":"a683719631b4720b","repo":"wagoodman/dive","slug":"failed-to-unmarshal-ci-config-file-s-w","errorCode":null,"errorMessage":"failed to unmarshal CI config file %s: %w","messagePattern":"failed to unmarshal CI config file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/dive/cli/internal/options/ci.go","lineNumber":69,"sourceCode":"\t\t\t// If we're hitting this case we should pretend that only the config file was provided and applied\n\t\t\t// on top of the default config values.\n\t\t\tyamlFile, err := os.ReadFile(c.ConfigPath)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to read CI config file %s: %w\", c.ConfigPath, err)\n\t\t\t}\n\t\t\tdef := DefaultCIRules()\n\t\t\tr := legacyRuleFile{\n\t\t\t\tLowestEfficiencyThresholdString: def.LowestEfficiencyThresholdString,\n\t\t\t\tHighestWastedBytesString:        def.HighestWastedBytesString,\n\t\t\t\tHighestUserWastedPercentString:  def.HighestUserWastedPercentString,\n\t\t\t}\n\t\t\twrapper := struct {\n\t\t\t\tRules *legacyRuleFile `yaml:\"rules\"`\n\t\t\t}{\n\t\t\t\tRules: &r,\n\t\t\t}\n\t\t\tif err := yaml.Unmarshal(yamlFile, &wrapper); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to unmarshal CI config file %s: %w\", c.ConfigPath, err)\n\t\t\t}\n\t\t\t// TODO: should this be a deprecated use warning in the future?\n\t\t\tc.Rules = CIRules{\n\t\t\t\tLowestEfficiencyThresholdString: r.LowestEfficiencyThresholdString,\n\t\t\t\tHighestWastedBytesString:        r.HighestWastedBytesString,\n\t\t\t\tHighestUserWastedPercentString:  r.HighestUserWastedPercentString,\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\ntype legacyRuleFile struct {\n\tLowestEfficiencyThresholdString string `yaml:\"lowestEfficiency\"`\n\tHighestWastedBytesString        string `yaml:\"highestWastedBytes\"`\n\tHighestUserWastedPercentString  string `yaml:\"highestUserWastedPercent\"`\n}","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/wagoodman/dive/blob/d6c691947f8fda635c952a17ee3b7555379d58f0/cmd/dive/cli/internal/options/ci.go#L51-L87","documentation":"Thrown when yaml.Unmarshal of the CI rules file contents into the legacy rules wrapper struct fails. The file was read successfully but its YAML does not match the expected schema (a top-level 'rules' key with the three threshold string fields). The %w carries the go-yaml parse/type error with line information.","triggerScenarios":"Supplying --ci-config with a file that has YAML syntax errors (tabs, bad indentation) or semantically wrong types, e.g. rules.lowestEfficiencyThreshold given as a nested map or list instead of a string, or a completely different YAML document (a docker-compose file by mistake).","commonSituations":"Reusing an old dive config (dive.yaml) whose structure changed; hand-editing thresholds and breaking indentation; passing the application config file where a CI-rules-only file was expected; duplicate keys.","solutions":["Read the wrapped yaml error line/column and fix the YAML syntax at that location.","Compare against the expected schema: top-level 'rules:' with 'lowestEfficiencyThreshold', 'highestWastedBytes', 'highestUserWastedPercent' as scalar values.","Validate the file with a YAML linter (yamllint) or 'yq .' before running dive.","Drop --ci-config to use DefaultCIRules() and re-add thresholds incrementally."],"exampleFix":"# before (ci-rules.yaml)\nrules:\n  lowestEfficiencyThreshold:   # missing value -> unmarshal error\n\n# after\nrules:\n  lowestEfficiencyThreshold: \"0.9\"\n  highestWastedBytes: \"50MB\"\n  highestUserWastedPercent: \"0.6\"","handlingStrategy":"validation","validationCode":"# lint the CI rules file before dive runs\nyamllint ci-rules.yaml || exit 1\nyq '.rules | keys' ci-rules.yaml  # expect the three threshold keys","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Template CI rule files from a single reviewed source instead of hand-editing.","Keep threshold values as quoted strings matching the documented schema.","Run yamllint/yq in CI before the dive step."],"tags":["dive","ci","yaml","configuration","cli"],"backgroundTag":null,"analyzedSha":"d6c691947f8fda635c952a17ee3b7555379d58f0","analyzedAt":"2026-08-15T09:42:35.293Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}