Tencent/WeKnora · error

unknown credential field: %s

Error message

unknown credential field: %s

What it means

Validation in ClearMCPCredential's field switch: the requested credential field is neither 'api_key' nor 'token', the only two clearable fields. Any other field name is rejected to avoid silently pretending to clear an unknown key; fix by passing one of the supported field identifiers.

Source

Thrown at internal/application/service/mcp_service.go:568

	}
	if existing.AuthConfig == nil {
		return nil // nothing to clear
	}

	changed := false
	switch field {
	case "api_key":
		if existing.AuthConfig.APIKey != "" {
			existing.AuthConfig.APIKey = ""
			changed = true
		}
	case "token":
		if existing.AuthConfig.Token != "" {
			existing.AuthConfig.Token = ""
			changed = true
		}
	default:
		return fmt.Errorf("unknown credential field: %s", field)
	}
	if !changed {
		return nil
	}

	existing.UpdatedAt = time.Now()
	if err := s.mcpServiceRepo.Update(ctx, existing); err != nil {
		return fmt.Errorf("failed to update MCP service: %w", err)
	}

	s.mcpManager.CloseClient(id)
	logger.GetLogger(ctx).Infof(
		"MCP credential cleared by user: id=%s field=%s, connection closed",
		secutils.SanitizeForLog(id), field,
	)
	return nil
}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Use 'api_key' or 'token' as the field value
  2. Validate the field against the allowed set client-side before calling
  3. Document supported fields in the API contract
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/application/service/mcp_service.go:568 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/fd6e509289b61773. Report an issue: GitHub.