{"record":{"id":"bf622eb028118b2f","repo":"getsops/sops","slug":"error-loading-config-no-matching-destination-foun","errorCode":null,"errorMessage":"error loading config: no matching destination found in config","messagePattern":"error loading config: no matching destination found in config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":532,"sourceCode":"\tif len(conf.DestinationRules) > 0 {\n\t\tfor _, r := range conf.DestinationRules {\n\t\t\tif r.PathRegex == \"\" {\n\t\t\t\tdRule = &r\n\t\t\t\trule = &dRule.RecreationRule\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif r.PathRegex != \"\" {\n\t\t\t\tif match, _ := regexp.MatchString(r.PathRegex, filePath); match {\n\t\t\t\t\tdRule = &r\n\t\t\t\t\trule = &dRule.RecreationRule\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif dRule == nil {\n\t\treturn nil, fmt.Errorf(\"error loading config: no matching destination found in config\")\n\t}\n\n\tvar dest publish.Destination\n\tdestinationCount := 0\n\tif dRule.S3Bucket != \"\" {\n\t\tdestinationCount++\n\t}\n\tif dRule.GCSBucket != \"\" {\n\t\tdestinationCount++\n\t}\n\tif dRule.VaultPath != \"\" {\n\t\tdestinationCount++\n\t}\n\n\tif destinationCount > 1 {\n\t\treturn nil, fmt.Errorf(\"error loading config: more than one destinations were found in a single destination rule, you can only use one per rule\")\n\t}\n\tif dRule.S3Bucket != \"\" {","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/config/config.go#L514-L550","documentation":"When a file matches a destination rule (or a rule is otherwise resolved), sops must find the matching dRule; if dRule is nil — no destination rule matched — config loading fails. This error means the lookup produced no destination rule, so sops cannot determine where the encrypted file should be published.","triggerScenarios":"Evaluating destination_rules against a file path where every rule's path_regex fails to match, or a destination_rules block exists but its match criteria exclude the current file, leaving dRule nil.","commonSituations":"Typo in the destination rule's path_regex; file located in a directory not covered by any destination rule; destination_rules added but expected match string doesn't account for the absolute vs relative path passed to sops.","solutions":["Broaden or fix the path_regex on the intended destination rule so it matches the file path passed to sops","Confirm the value passed to sops (relative vs absolute path) matches what the regex anchors against — add ^ or .* accordingly","Add a catch-all destination rule (path_regex: '.*') as the last entry if every file should publish somewhere","Verify the rule key names (s3_bucket, gcs_bucket, vault_path) are spelled correctly inside the rule"],"exampleFix":"# before\ndestination_rules:\n  - path_regex: 'prod/.*'\n    s3_bucket: 'my-bucket'\n# after\ndestination_rules:\n  - path_regex: '.*prod.*'\n    s3_bucket: 'my-bucket'","handlingStrategy":"validation","validationCode":"matched := false\nfor _, r := range cfg.DestinationRules {\n    if re, err := regexp.Compile(r.PathRegex); err == nil && re.MatchString(filePath) {\n        matched = true\n        break\n    }\n}\nif !matched {\n    return fmt.Errorf(\"no destination rule matches %s\", filePath)\n}","typeGuard":null,"tryCatchPattern":"cfg, err := loadConfigForFile(path)\nif err != nil && strings.Contains(err.Error(), \"no matching destination found\") {\n    return fmt.Errorf(\"add a destination rule covering %s\", path)\n}","preventionTips":["Test path_regex values against the exact paths passed to sops in your scripts","Keep a catch-all destination rule as the last entry if uploads are mandatory","Re-check destination rules after renaming or moving directories"],"tags":["config","destination-rules","sops"],"backgroundTag":"no-matching-config-rule","analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}