chenhg5/cc-connect · error
yuanbao platform located in parsed config but not raw file
Error message
yuanbao platform located in parsed config but not raw file
What it means
The sibling of the project-span invariant error: the project span exists but spans[projectIdx].platforms has no entry at absIdx, meaning the raw-line platform-span builder counted fewer platforms inside the project block than the TOML parser did. This is a disagreement between the parsed config model and the line-based raw span model used for in-place text edits.
Source
Thrown at config/config.go:2777
if platform.Options == nil {
platform.Options = map[string]any{}
}
platform.Options["bot_token"] = botToken
allowFrom := strings.TrimSpace(stringOption(platform.Options["allow_from"]))
if v := strings.TrimSpace(opts.AllowFrom); v != "" {
allowFrom = v
platform.Options["allow_from"] = v
}
lines, hadTrailing := splitConfigLines(raw)
spans := buildRawProjectSpans(lines)
if projectIdx >= len(spans) {
return nil, fmt.Errorf("project %q located in parsed config but not raw file", opts.ProjectName)
}
if absIdx >= len(spans[projectIdx].platforms) {
return nil, fmt.Errorf("yuanbao platform located in parsed config but not raw file")
}
reloadSpan := func() rawPlatformSpan {
spans = buildRawProjectSpans(lines)
return spans[projectIdx].platforms[absIdx]
}
span := reloadSpan()
if span.optionsStart < 0 {
insertAt := span.end + 1
block := make([]string, 0, 4)
if insertAt > 0 && strings.TrimSpace(lines[insertAt-1]) != "" {
block = append(block, "")
}
block = append(block, "[projects.platforms.options]")
if insertAt < len(lines) && strings.TrimSpace(lines[insertAt]) != "" {
block = append(block, "")
}View on GitHub (pinned to 4000b2338a)
Solutions
- Normalize all platforms in the project to standard `[[projects.platforms]]` blocks via a TOML formatter
- Retry the operation after rewriting; if it persists with conventional TOML, file a bug with the config structure (redact tokens)
- As a workaround, regenerate the platform entry via the library's add API instead of in-place editing
Example fix
// before
platforms = [{type="yuanbao", bot_token="k:s"}] // inline inside [[projects]]
// after
[[projects]]
name = "a"
[[projects.platforms]]
type = "yuanbao"
bot_token = "k:s" Defensive patterns
Strategy: try-catch
Validate before calling
// internal invariant; no meaningful caller-side pre-check beyond normalizing TOML layout
if err != nil && strings.Contains(err.Error(), "not raw file") {
return fmt.Errorf("expand inline platform tables into [[projects.platforms]] blocks and retry")
} Try / catch
if err != nil {
if strings.Contains(err.Error(), "yuanbao platform located in parsed config but not raw file") {
slog.Error("raw platform spans out of sync with parsed config; rewrite platform blocks as array-of-tables", "err", err)
return err
}
return err
} Prevention
- Keep every platform as its own [[projects.platforms]] block — no inline tables
- Avoid dotted-key platform definitions (projects.platforms.type = ...)
- Back up config.toml before automated edits, and retry the operation after reformatting
When it happens
Trigger: Platforms inside a [[projects]] block written in a form buildRawProjectSpans misses (inline tables, dotted keys, unusual indentation/headers), so the raw span list is shorter than cfg.Projects[projectIdx].Platforms; a comment or heredoc-like content swallowing a `[[projects.platforms]]` header during line scanning.
Common situations: Same as 618 but at platform granularity: a config partially reformatted so some platforms are inline and some are full tables; a third-party tool appending platforms in a non-standard layout.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- project %q located in parsed config but not raw file
- reload config: %w
- config: %s.mode must be "full", "compact", or "quiet"
- config: %s.card_mode must be "legacy" or "rich"
- encode config: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/8ab6ad660288daa8.
Report an issue: GitHub.