Tencent/WeKnora · error
marshal credentials: %w
Error message
marshal credentials: %w
What it means
Fires in parseIMAConfig when json.Marshal cannot serialize the datasource's Credentials map into JSON. With map credentials this is practically unreachable, so it signals a genuinely malformed credential value rather than user error.
Source
Thrown at internal/datasource/connector/ima/types.go:63
url := strings.TrimSpace(c.BaseURL)
if url == "" {
return DefaultBaseURL
}
if !strings.Contains(url, "://") {
url = "https://" + url
}
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 }`.View on GitHub (pinned to 988cbb0330)
Solutions
- Inspect config.Credentials for unsupported or corrupted values
- Log the underlying marshal error to identify the offending credential key
- If credentials come from a store, validate them before passing to parseIMAConfig
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/datasource/connector/ima/types.go:63 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/53a0a30d50915310.
Report an issue: GitHub.