chenhg5/cc-connect · error

platform %q not found for session %q

Error message

platform %q not found for session %q

What it means

ExecuteCronJob derives the platform name from the cron job's session key (the prefix before the first ':', or a known platform name found inside the key) and looks it up among registered platforms. If no registered platform matches — the prefix is not a live platform name — the engine returns 'platform %q not found for session %q'. This means the cron job references a platform that is not configured, disabled at build time, or whose name changed.

Source

Thrown at core/engine.go:1498

			break
		}
	}
	// Fallback: in multi-workspace mode the stored session key may be prefixed
	// with the workspace path (e.g. "/home/user/project:slack:C123:U456").
	// Search for a known platform name within the key and strip the prefix.
	if targetPlatform == nil {
		for _, p := range e.platforms {
			needle := ":" + p.Name() + ":"
			if idx := strings.Index(sessionKey, needle); idx >= 0 {
				targetPlatform = p
				platformName = p.Name()
				sessionKey = sessionKey[idx+1:] // strip workspace prefix
				break
			}
		}
	}
	if targetPlatform == nil {
		return fmt.Errorf("platform %q not found for session %q", platformName, sessionKey)
	}

	rc, ok := targetPlatform.(ReplyContextReconstructor)
	if !ok {
		return fmt.Errorf("platform %q does not support proactive messaging (cron)", platformName)
	}

	runSessionKey := sessionKey
	var replyCtx any
	var err error
	if !job.Mute {
		if resolver, ok := targetPlatform.(CronReplyTargetResolver); ok {
			resolvedSessionKey, resolvedReplyCtx, err := resolver.ResolveCronReplyTarget(sessionKey, cronRunTitle(job))
			if err != nil {
				if !errors.Is(err, ErrNotSupported) {
					return fmt.Errorf("resolve cron reply target: %w", err)
				}
			} else {

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Check config.toml: ensure the platform named in the session key prefix is configured and enabled.
  2. Rebuild without the excluding build tag/EXCLUDE entry (e.g. remove no_slack from tags, drop the platform from EXCLUDE=).
  3. Delete or re-create the stale cron job (its session key references a removed platform): use the cron listing command or clear persisted cron state.
  4. Verify the session key format: it must contain a registered platform name (p.Name()) — fix typos like 'telegramm:...'.
  5. If the platform was renamed across versions, update the persisted cron job's session key to the new platform name.

Example fix

// before: cron job persisted for a platform no longer configured
// config.toml
# [[platforms]]
# name = "discord"   # removed, but cron jobs still reference it
// after: re-enable the platform or purge stale jobs
[[platforms]]
name = "discord"
# ... then delete stale jobs: cc-connect cron list / cron rm <id>
Defensive patterns

Strategy: validation

Validate before calling

// Go: validate cron job targets before persisting
func validCronTarget(platforms []core.Platform, sessionKey string) bool {
    name := sessionKey
    if i := strings.Index(sessionKey, ":"); i > 0 { name = sessionKey[:i] }
    for _, p := range platforms {
        if p.Name() == name { return true }
    }
    return false
}

Try / catch

if err := engine.ExecuteCronJob(job); err != nil {
    var notFound *fmt.Errorf
    if strings.Contains(err.Error(), "not found for session") {
        slog.Error("cron job references missing platform; disabling job",
            "job", job.ID, "err", err)
        cronStore.Remove(job.ID)
    }
}

Prevention

When it happens

Trigger: A CronJob whose SessionKey's platform prefix (e.g. "feishu:..." or "/ws:path:slack:C123:U456") matches no platform in e.platforms: platform not present in config.toml, excluded via build tag (e.g. no_slack) or EXCLUDE=, platform name typo, or session key created under an older config with a differently named platform.

Common situations: Cron jobs persisted in state survive a config edit that removes/renames the platform; selective compilation (make build EXCLUDE=discord) silently drops the platform; multi-workspace session keys whose embedded platform segment doesn't match any registered p.Name().

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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