{"record":{"id":"09e5b1387eac94b0","repo":"ory/kratos","slug":"expected-to-find-const-s-in-text-id-go","errorCode":null,"errorMessage":"expected to find const %s in text/id.go","messagePattern":"expected to find const (.+?) in text/id\\.go","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/clidoc/main.go","lineNumber":389,"sourceCode":"\tfor _, f := range pack.Files {\n\t\tfor _, d := range f.Decls {\n\t\t\tswitch decl := d.(type) {\n\t\t\tcase *ast.FuncDecl:\n\t\t\t\tif name := decl.Name.String(); decl.Name.IsExported() && strings.HasPrefix(name, \"New\") {\n\t\t\t\t\tif _, ok := messages[name]; !ok {\n\t\t\t\t\t\treturn errors.Errorf(\"expected to find message %s in the list for the documentation generation but could not\", name)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase *ast.GenDecl:\n\t\t\t\tif decl.Tok == token.CONST {\n\t\t\t\t\tfor _, spec := range decl.Specs {\n\t\t\t\t\t\tvalue := spec.(*ast.ValueSpec) // safe because decl.Tok is token.CONST\n\t\t\t\t\t\tif t, ok := value.Type.(*ast.Ident); ok {\n\t\t\t\t\t\t\tif t.Name == \"ID\" {\n\t\t\t\t\t\t\t\tfor _, name := range value.Names {\n\t\t\t\t\t\t\t\t\tc := info.ObjectOf(name)\n\t\t\t\t\t\t\t\t\tif c == nil {\n\t\t\t\t\t\t\t\t\t\treturn errors.Errorf(\"expected to find const %s in text/id.go\", name.Name)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tusedIDs = append(usedIDs, message{\n\t\t\t\t\t\t\t\t\t\tID:   c.(*types.Const).Val().ExactString(),\n\t\t\t\t\t\t\t\t\t\tName: name.Name,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tsort.Slice(usedIDs, func(i, j int) bool {\n\t\treturn usedIDs[i].ID < usedIDs[j].ID\n\t})\n\tfor i := 1; i < len(usedIDs); i++ {","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/ory/kratos/blob/b86338da04a040247a07f46100a86dcfb3875909/cmd/clidoc/main.go#L371-L407","documentation":"validateAllMessages cross-checks each entry in the generator's messages map against the constants declared in text/id.go. A message known to the generator has no matching const declaration in that file, so the registry references a constant that does not exist in source.","triggerScenarios":"Thrown at cmd/clidoc/main.go:389 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the missing const with the message's name to text/id.go","If the message was removed, delete its entry from the messages map in cmd/clidoc/main.go","Keep the const name exactly matching what the generator expects"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b86338da04a040247a07f46100a86dcfb3875909","analyzedAt":"2026-09-07T15:58:15.934Z","contentChangedAt":"2026-09-07T15:58:15.934Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}