chenhg5/cc-connect · error

%s: client not initialized

Error message

%s: client not initialized

What it means

A recall-check lookup needs the Lark API client, but p.client is nil — the platform's client was never initialized. This is an internal invariant violation: the platform should have created its client in newPlatform/Start before handling messages.

Source

Thrown at platform/feishu/feishu.go:1131

	for _, needle := range []string{"withdrawn", "recalled", "recall", "deleted", "not found", "not exist", "撤回"} {
		if strings.Contains(msg, needle) {
			return true
		}
	}
	return false
}

func (p *Platform) IsMessageRecalled(ctx context.Context, rctx any) (bool, error) {
	rc, ok := rctx.(replyContext)
	if !ok || strings.TrimSpace(rc.messageID) == "" {
		return false, nil
	}
	messageID := strings.TrimSpace(rc.messageID)
	if p.isMessageRecalled(messageID) {
		return true, nil
	}
	if p.client == nil {
		return false, fmt.Errorf("%s: client not initialized", p.tag())
	}

	req := larkim.NewGetMessageReqBuilder().
		MessageId(messageID).
		UserIdType(larkim.UserIdTypeGetMessageOpenId).
		Build()

	var resp *larkim.GetMessageResp
	if err := p.withTransientRetry(ctx, "get message", func() error {
		return p.withFreshTenantAccessTokenRetry(ctx, "get message", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {
			var err error
			resp, err = client.Im.Message.Get(ctx, req, options...)
			if err != nil {
				return fmt.Errorf("%s: get message api call: %w", p.tag(), err)
			}
			if !resp.Success() {
				return fmt.Errorf("%s: get message failed code=%d msg=%s", p.tag(), resp.Code, resp.Msg)
			}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Ensure the platform started successfully (check startup logs for earlier init errors) before messages flow.
  2. Verify app_id/app_secret are valid so client construction doesn't fail silently.
  3. Restart cc-connect; if reproducible, report as a bug — this indicates a startup-order defect.
Defensive patterns

Strategy: fallback

Type guard

func (p *Platform) clientReady() bool { return p.client != nil }

Try / catch

if !p.clientReady() {
    // degrade: assume not recalled instead of failing the message flow
    return false, nil
}

Prevention

When it happens

Trigger: Invoking the message-recall check (isMessageRecalled path) before Start() initializes the client, or after a failed initialization, on a message containing a resource reference.

Common situations: Partial startup failure (credential error swallowed elsewhere); calling platform methods directly in tests without a started platform; race between message delivery and platform initialization.

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/e7b4ba954dcf34fa. Report an issue: GitHub.