{"record":{"id":"120bda6a50646f0f","repo":"Tencent/WeKnora","slug":"empty-result-120bda","errorCode":null,"errorMessage":"empty result","messagePattern":"empty result","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/wiki_link_mutation.go","lineNumber":35,"sourceCode":"}\n\n// applyIncomingWikiContentRewrite updates machine-maintained links without\n// incrementing user-visible page versions. It stops on the first failure and\n// returns the already-applied changes so the caller can compensate.\nfunc applyIncomingWikiContentRewrite(\n\tctx context.Context,\n\tservice interfaces.WikiPageService,\n\tkbID string,\n\tinLinks []string,\n\trewrite wikiContentRewrite,\n) ([]appliedWikiContentChange, []string, error) {\n\tvar changes []appliedWikiContentChange\n\tvar updatedSlugs []string\n\tfor _, sourceSlug := range dedupNonEmptyStrings(inLinks) {\n\t\tpage, err := service.GetPageBySlug(ctx, kbID, sourceSlug)\n\t\tif err != nil || page == nil {\n\t\t\tif err == nil {\n\t\t\t\terr = fmt.Errorf(\"empty result\")\n\t\t\t}\n\t\t\treturn changes, updatedSlugs, fmt.Errorf(\"load incoming page %s: %w\", sourceSlug, err)\n\t\t}\n\t\tupdatedContent, changed := rewrite(page.Content)\n\t\tif !changed {\n\t\t\tcontinue\n\t\t}\n\t\toriginal := page.Content\n\t\tpage.Content = updatedContent\n\t\tif err := service.UpdateAutoLinkedContent(ctx, page); err != nil {\n\t\t\tpage.Content = original\n\t\t\treturn changes, updatedSlugs, fmt.Errorf(\"update incoming page %s: %w\", sourceSlug, err)\n\t\t}\n\t\tchanges = append(changes, appliedWikiContentChange{page: page, originalContent: original})\n\t\tupdatedSlugs = append(updatedSlugs, sourceSlug)\n\t}\n\treturn changes, updatedSlugs, nil\n}","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/wiki_link_mutation.go#L17-L53","documentation":"Sentinel inner error produced when GetPageBySlug returns no error but a nil page while rewriting incoming wiki links: the storage 'succeeded' with nothing, so this guard substitutes a non-nil error so the caller's load-failure wrapping has a cause to chain; the loop stops and already-applied changes are returned for compensation.","triggerScenarios":"Thrown at internal/agent/tools/wiki_link_mutation.go:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the incoming-link slug actually exists as a page","Check for stale incoming-link metadata referencing deleted pages","Make the storage layer return a typed not-found error instead of nil,nil"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}