{"record":{"id":"b33f2f1fa0922478","repo":"Tencent/WeKnora","slug":"w-client-id-is-required","errorCode":null,"errorMessage":"%w: client_id is required","messagePattern":"%w: client_id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/datasource/connector/ima/types.go","lineNumber":70,"sourceCode":"\treturn strings.TrimRight(url, \"/\")\n}\n\n// parseIMAConfig extracts and validates IMA-specific configuration.\n// Uses JSON marshal/unmarshal roundtrip so extra fields are ignored gracefully.\nfunc parseIMAConfig(config *types.DataSourceConfig) (*Config, error) {\n\tif config == nil {\n\t\treturn nil, fmt.Errorf(\"%w: config is nil\", datasource.ErrInvalidConfig)\n\t}\n\tcredBytes, err := json.Marshal(config.Credentials)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"marshal credentials: %w\", err)\n\t}\n\tvar cfg Config\n\tif err := json.Unmarshal(credBytes, &cfg); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse ima credentials: %w\", err)\n\t}\n\tif strings.TrimSpace(cfg.ClientID) == \"\" {\n\t\treturn nil, fmt.Errorf(\"%w: client_id is required\", datasource.ErrInvalidCredentials)\n\t}\n\tif strings.TrimSpace(cfg.APIKey) == \"\" {\n\t\treturn nil, fmt.Errorf(\"%w: api_key is required\", datasource.ErrInvalidCredentials)\n\t}\n\tif err := datasource.ValidateConnectorBaseURL(cfg.GetBaseURL()); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &cfg, nil\n}\n\n// apiEnvelope is the uniform IMA response wrapper: `{ code, msg, data }`.\n// A non-zero code is a business-level error and MUST be surfaced to the user.\n//\n// Some published IMA references spell the same envelope `{ retcode, errmsg }`.\n// Accepting both costs nothing and avoids the failure mode where a mismatch\n// leaves Code at its zero value and every API error is silently read as\n// success.\ntype apiEnvelope struct {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/datasource/connector/ima/types.go#L52-L88","documentation":"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.","triggerScenarios":"Thrown at internal/datasource/connector/ima/types.go:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set client_id in the IMA datasource credentials","Check for trimmed/emptied values from env or secret stores","Re-enter credentials in the datasource configuration UI"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}