{"record":{"id":"df90173c6a1a360d","repo":"chenhg5/cc-connect","slug":"feishu-lark-platform-located-in-parsed-config-but","errorCode":null,"errorMessage":"feishu/lark platform located in parsed config but not raw file","messagePattern":"feishu/lark platform located in parsed config but not raw file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":2109,"sourceCode":"\n\tplatform.Options[\"app_id\"] = strings.TrimSpace(opts.AppID)\n\tplatform.Options[\"app_secret\"] = strings.TrimSpace(opts.AppSecret)\n\n\tallowFrom := strings.TrimSpace(stringOption(platform.Options[\"allow_from\"]))\n\tif opts.SetAllowFromEmpty && strings.TrimSpace(opts.OwnerOpenID) != \"\" {\n\t\tallowFrom = mergeAllowFromValue(allowFrom, strings.TrimSpace(opts.OwnerOpenID))\n\t\tif allowFrom != \"\" {\n\t\t\tplatform.Options[\"allow_from\"] = allowFrom\n\t\t}\n\t}\n\n\tlines, hadTrailing := splitConfigLines(raw)\n\tspans := buildRawProjectSpans(lines)\n\tif projectIdx >= len(spans) {\n\t\treturn nil, fmt.Errorf(\"project %q located in parsed config but not raw file\", opts.ProjectName)\n\t}\n\tif absIdx >= len(spans[projectIdx].platforms) {\n\t\treturn nil, fmt.Errorf(\"feishu/lark platform located in parsed config but not raw file\")\n\t}\n\n\treloadSpan := func() rawPlatformSpan {\n\t\tspans = buildRawProjectSpans(lines)\n\t\treturn spans[projectIdx].platforms[absIdx]\n\t}\n\tspan := spans[projectIdx].platforms[absIdx]\n\n\tif opts.PlatformType != \"\" {\n\t\tif span.typeLine >= 0 {\n\t\t\tlines[span.typeLine] = replaceTomlStringKeyLine(lines[span.typeLine], \"type\", opts.PlatformType)\n\t\t} else {\n\t\t\tlines = insertLines(lines, span.start+1, []string{fmt.Sprintf(\"type = %s\", quoteTomlString(opts.PlatformType))})\n\t\t}\n\t\tspan = reloadSpan()\n\t}\n\n\tif span.optionsStart < 0 {","sourceCodeStart":2091,"sourceCodeEnd":2127,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/config/config.go#L2091-L2127","documentation":"Companion to the previous error: the project span was found in the raw file, but the resolved absolute platform index (absIdx) has no corresponding platform span inside that project's raw block. Again a parsed-vs-raw consistency failure inside the helper's in-place editing machinery.","triggerScenarios":"Calling the ensure-feishu-platform API (config/config.go:2109) when buildRawProjectSpans finds fewer platform sub-blocks inside the project's raw span than the TOML parser found — e.g. nested/unusual platform table formatting the raw scanner miscounts.","commonSituations":"Platforms declared with non-standard formatting (inline tables, dotted keys like projects.platforms.type) that the raw span builder does not count; commented-out platform blocks shifting the raw scan; concurrent file edits.","solutions":["Rewrite platform entries as standard [[projects.platforms]] blocks in config.toml.","Remove commented-out or malformed platform table headers inside the project block.","File a bug with the config content (secrets redacted) if standard formatting still triggers it."],"exampleFix":"# before (raw scanner may miscount)\n[projects.platforms]\ntype = \"feishu\"\n# after\n[[projects.platforms]]\ntype = \"feishu\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"not raw file\") {\n    slog.Error(\"raw/parsed config mismatch; falling back to full-file rewrite\", \"err\", err)\n    // fallback: regenerate the config via the structured TOML encoder instead of in-place span editing\n}","preventionTips":["Use standard array-of-tables syntax for platforms","Remove commented-out platform table headers","Test config edits against a copy of config.toml first"],"tags":["go","config","internal"],"backgroundTag":"internal-invariant-violation","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}