chenhg5/cc-connect · error

weixin platform located in parsed config but not raw file

Error message

weixin platform located in parsed config but not raw file

What it means

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.

Source

Thrown at config/config.go:2480

	if id := strings.TrimSpace(opts.AccountID); id != "" {
		platform.Options["account_id"] = id
	}

	allowFrom := strings.TrimSpace(stringOption(platform.Options["allow_from"]))
	if opts.SetAllowFromEmpty && strings.TrimSpace(opts.ScannedUserID) != "" {
		allowFrom = mergeAllowFromValue(allowFrom, strings.TrimSpace(opts.ScannedUserID))
		if allowFrom != "" {
			platform.Options["allow_from"] = allowFrom
		}
	}

	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("weixin platform located in parsed config but not raw file")
	}

	reloadSpan := func() rawPlatformSpan {
		spans = buildRawProjectSpans(lines)
		return spans[projectIdx].platforms[absIdx]
	}
	span := spans[projectIdx].platforms[absIdx]

	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

  1. Inspect the project's platform blocks in config.toml and rewrite them in standard [[projects.platforms]] form
  2. Avoid concurrent edits to config.toml while running credential setup
  3. Retry after reformatting; if it still fails with valid TOML, report as a bug in the raw span parser
Defensive patterns

Strategy: try-catch

Validate before calling

null

Try / catch

res, err := SaveWeixinPlatformCredentials(opts)
if err != nil && strings.Contains(err.Error(), "not raw file") {
    // restore from backup and re-run with standardized TOML formatting
    restoreBackup(configPath)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/440e6a1c56c389ad. Report an issue: GitHub.