{"record":{"id":"440e6a1c56c389ad","repo":"chenhg5/cc-connect","slug":"weixin-platform-located-in-parsed-config-but-not-r","errorCode":null,"errorMessage":"weixin platform located in parsed config but not raw file","messagePattern":"weixin platform located in parsed config but not raw file","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":2480,"sourceCode":"\tif id := strings.TrimSpace(opts.AccountID); id != \"\" {\n\t\tplatform.Options[\"account_id\"] = id\n\t}\n\n\tallowFrom := strings.TrimSpace(stringOption(platform.Options[\"allow_from\"]))\n\tif opts.SetAllowFromEmpty && strings.TrimSpace(opts.ScannedUserID) != \"\" {\n\t\tallowFrom = mergeAllowFromValue(allowFrom, strings.TrimSpace(opts.ScannedUserID))\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(\"weixin 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 span.optionsStart < 0 {\n\t\tinsertAt := span.end + 1\n\t\tblock := make([]string, 0, 4)\n\t\tif insertAt > 0 && strings.TrimSpace(lines[insertAt-1]) != \"\" {\n\t\t\tblock = append(block, \"\")\n\t\t}\n\t\tblock = append(block, \"[projects.platforms.options]\")\n\t\tif insertAt < len(lines) && strings.TrimSpace(lines[insertAt]) != \"\" {\n\t\t\tblock = append(block, \"\")\n\t\t}","sourceCodeStart":2462,"sourceCodeEnd":2498,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/config/config.go#L2462-L2498","documentation":"The specific weixin platform (by absolute index within the project) found in the parsed TOML could not be matched to a platform span in the raw file lines. Like error 602, this is a consistency check between the parsed model and the line-based raw span parser before in-place editing of the platform's options.","triggerScenarios":"The project's platform blocks exist in parsed config but buildRawProjectSpans records fewer platform spans for that project — typically due to odd nesting/formatting of [[projects.platforms]] blocks, or the raw file changing between read and span build.","commonSituations":"Hand-edited or tool-generated TOML where platform headers don't match the expected [[projects.platforms]] pattern the span parser looks for; concurrent config mutation during a credential update.","solutions":["Inspect the project's platform blocks in config.toml and rewrite them in standard [[projects.platforms]] form","Avoid concurrent edits to config.toml while running credential setup","Retry after reformatting; if it still fails with valid TOML, report as a bug in the raw span parser"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":null,"tryCatchPattern":"res, err := SaveWeixinPlatformCredentials(opts)\nif err != nil && strings.Contains(err.Error(), \"not raw file\") {\n    // restore from backup and re-run with standardized TOML formatting\n    restoreBackup(configPath)\n}","preventionTips":["Write platform blocks in canonical [[projects.platforms]] form","Don't mix generation tools that reformat the same config.toml","Back up the config before credential updates"],"tags":["config","invariant","raw-parsing","weixin"],"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"}