{"record":{"id":"5cbed64b4c0ef094","repo":"go-delve/delve","slug":"could-not-find-rule-for-q-5cbed6","errorCode":null,"errorMessage":"could not find rule for %q","messagePattern":"could not find rule for %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/dap/config.go","lineNumber":81,"sourceCode":"\targv := config.SplitQuotedFields(rest, '\"')\n\tif len(argv) == 2 && argv[0] == \"-clear\" {\n\t\targv = argv[1:]\n\t}\n\tswitch len(argv) {\n\tcase 0:\n\t\t// do nothing, let caller show the current list of substitute path rules\n\t\treturn nil\n\tcase 1: // delete substitute-path rule\n\t\tfor i := range args.substitutePathClientToServer {\n\t\t\tif args.substitutePathClientToServer[i][0] == argv[0] {\n\t\t\t\tcopy(args.substitutePathClientToServer[i:], args.substitutePathClientToServer[i+1:])\n\t\t\t\targs.substitutePathClientToServer = args.substitutePathClientToServer[:len(args.substitutePathClientToServer)-1]\n\t\t\t\tcopy(args.substitutePathServerToClient[i:], args.substitutePathServerToClient[i+1:])\n\t\t\t\targs.substitutePathServerToClient = args.substitutePathServerToClient[:len(args.substitutePathServerToClient)-1]\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"could not find rule for %q\", argv[0])\n\tcase 2: // add substitute-path rule\n\t\tfor i := range args.substitutePathClientToServer {\n\t\t\tif args.substitutePathClientToServer[i][0] == argv[0] {\n\t\t\t\targs.substitutePathClientToServer[i][1] = argv[1]\n\t\t\t\targs.substitutePathServerToClient[i][0] = argv[1]\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\targs.substitutePathClientToServer = append(args.substitutePathClientToServer, [2]string{argv[0], argv[1]})\n\t\targs.substitutePathServerToClient = append(args.substitutePathServerToClient, [2]string{argv[1], argv[0]})\n\n\tdefault:\n\t\treturn errors.New(\"too many arguments to \\\"config substitutePath\\\"\")\n\t}\n\treturn nil\n}\n\nfunc configureSetShowPprofLabels(args *launchAttachArgs, rest string) error {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/dap/config.go#L63-L99","documentation":"When 'config substitutePath <path>' is called with exactly one argument, Delve interprets it as a delete request and searches existing substitutePath rules for a matching client path. If no rule matches, 'could not find rule for %q' is returned. Deleting requires an exact match of an existing rule's client-side path.","triggerScenarios":"Evaluating 'config substitutePath /client/path' where /client/path is not registered (typo, wrong case, never added, or already cleared with -clear).","commonSituations":"Trying to remove a rule defined in launch.json after a session restart that reset in-session rules; path case mismatch on Windows/case-sensitive mounts; trailing slash differences ('/src' vs '/src/'); assuming rules from a prior debug session persist.","solutions":["Run 'config substitutePath' with no arguments to list current rules and copy the exact client path.","Match the path byte-for-byte, including case and absence/presence of trailing slashes.","If the rule came from launch.json, remove it there (in-session rules reset between sessions).","Add the rule first with two arguments ('config substitutePath /client /server') before attempting deletion."],"exampleFix":"// before\ndebugConsole> config substitutePath /Src\n// after (exact existing rule)\nconfig substitutePath /src","handlingStrategy":"validation","validationCode":"// list current rules before deleting:\nout := runEval(\"config substitutePath\")\nexisting := parseClientPaths(out)\nif !existing[clientPath] {\n    return fmt.Errorf(\"no rule for %q; exact match required\", clientPath)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["List rules first and copy the exact client path","Beware trailing slashes and case differences","Remember in-session rules reset each session; manage launch.json rules there"],"tags":["dap","configuration","substitute-path"],"backgroundTag":"rule-not-found","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}