chenhg5/cc-connect · error
project %q located in parsed config but not raw file
Error message
project %q located in parsed config but not raw file
What it means
This is an internal consistency check: the project was found in the parsed TOML (projectIdx >= 0) but buildRawProjectSpans did not produce a raw-text span at that index. Since the surgical editor needs both views to agree, it fails rather than corrupting the file.
Source
Thrown at config/config.go:1240
if err := toml.Unmarshal(data, cfg); err != nil {
return fmt.Errorf("parse config: %w", err)
}
projectIdx := -1
for i := range cfg.Projects {
if cfg.Projects[i].Name == projectName {
projectIdx = i
break
}
}
if projectIdx < 0 {
return fmt.Errorf("project %q not found in config", projectName)
}
lines, hadTrailing := splitConfigLines(raw)
spans := buildRawProjectSpans(lines)
if projectIdx >= len(spans) {
return fmt.Errorf("project %q located in parsed config but not raw file", projectName)
}
projSpan := spans[projectIdx]
for j, prov := range cfg.Projects[projectIdx].Agent.Providers {
if prov.Name == providerName {
if j < len(projSpan.agentProviders) {
ps := projSpan.agentProviders[j]
lines = upsertTomlStringKey(lines, ps.start+1, ps.end, "model", model)
return writeRawConfig(joinConfigLines(lines, hadTrailing))
}
break
}
}
for _, ref := range cfg.Projects[projectIdx].Agent.ProviderRefs {
if ref == providerName {
return patchGlobalProviderField(lines, hadTrailing, cfg, providerName, "model", model)
}View on GitHub (pinned to 4000b2338a)
Solutions
- Report/inspect as a bug: dump the config and the wrapped error together
- Simplify the [[projects]] section formatting (one standard block per project) and retry
- Re-read the file — if it changed concurrently, retry the save once the writer settles
- Upgrade to a version where the raw-span parser matches the TOML parser
Defensive patterns
Strategy: fallback
Validate before calling
lines, _ := splitConfigLines(raw)
if projectIdx >= len(buildRawProjectSpans(lines)) {
return errors.New("raw/parsed mismatch; reformat [[projects]]")
} Try / catch
if err := config.SaveProviderModel(p, prov, model); err != nil {
if strings.Contains(err.Error(), "but not raw file") {
// fall back to full rewrite or ask user to reformat config
}
return err
} Prevention
- Keep [[projects]] blocks in a plain, standard shape (one table header per project)
- Avoid programmatic rewrites of config with other tools while the app runs
- Upgrade when the raw-span parser lags the schema; report mismatches as bugs
When it happens
Trigger: projectIdx >= len(spans) after buildRawProjectSpans(lines) — a mismatch between the parsed [[projects]] tables and the raw-line scanning, e.g. unusual table nesting, generated/duplicated headers, or a parser bug.
Common situations: Configs with non-standard [[projects]] placement or comments/formatting that confuse the raw span builder; concurrent edits rewrote the file between read and span build; a version skew where the raw-span parser lags the TOML schema.
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
- yuanbao platform located in parsed config but not raw file
- feishu/lark platform located in parsed config but not raw fi
- weixin platform located in parsed config but not raw file
- cron project not found
- attachment send is disabled by config
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/f63df5e4b43644c2.
Report an issue: GitHub.