Tencent/WeKnora · error

%w: client_id is required

Error message

%w: client_id is required

What it means

Validation guard in parseIMAConfig: after unmarshalling credentials, the IMA client_id field is empty or whitespace. It wraps datasource.ErrInvalidConfig so callers can treat it as a configuration problem, not a runtime fault.

Source

Thrown at internal/datasource/connector/ima/types.go:70

	return strings.TrimRight(url, "/")
}

// parseIMAConfig extracts and validates IMA-specific configuration.
// Uses JSON marshal/unmarshal roundtrip so extra fields are ignored gracefully.
func parseIMAConfig(config *types.DataSourceConfig) (*Config, error) {
	if config == nil {
		return nil, fmt.Errorf("%w: config is nil", datasource.ErrInvalidConfig)
	}
	credBytes, err := json.Marshal(config.Credentials)
	if err != nil {
		return nil, fmt.Errorf("marshal credentials: %w", err)
	}
	var cfg Config
	if err := json.Unmarshal(credBytes, &cfg); err != nil {
		return nil, fmt.Errorf("parse ima credentials: %w", err)
	}
	if strings.TrimSpace(cfg.ClientID) == "" {
		return nil, fmt.Errorf("%w: client_id is required", datasource.ErrInvalidCredentials)
	}
	if strings.TrimSpace(cfg.APIKey) == "" {
		return nil, fmt.Errorf("%w: api_key is required", datasource.ErrInvalidCredentials)
	}
	if err := datasource.ValidateConnectorBaseURL(cfg.GetBaseURL()); err != nil {
		return nil, err
	}
	return &cfg, nil
}

// apiEnvelope is the uniform IMA response wrapper: `{ code, msg, data }`.
// A non-zero code is a business-level error and MUST be surfaced to the user.
//
// Some published IMA references spell the same envelope `{ retcode, errmsg }`.
// Accepting both costs nothing and avoids the failure mode where a mismatch
// leaves Code at its zero value and every API error is silently read as
// success.
type apiEnvelope struct {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Set client_id in the IMA datasource credentials
  2. Check for trimmed/emptied values from env or secret stores
  3. Re-enter credentials in the datasource configuration UI
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/datasource/connector/ima/types.go:70 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/b33f2f1fa0922478. Report an issue: GitHub.