{"record":{"id":"a3a0dbb30150e617","repo":"Tencent/WeKnora","slug":"parse-rss-credentials-w","errorCode":null,"errorMessage":"parse rss credentials: %w","messagePattern":"parse rss credentials: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/datasource/connector/rss/types.go","lineNumber":65,"sourceCode":"\tFeedURLs string `json:\"feed_urls\"`\n\n\t// AuthHeaders is an optional newline-separated list of custom request\n\t// headers in \"Name: Value\" form, applied only to feed fetches.\n\tAuthHeaders string `json:\"auth_headers,omitempty\"`\n}\n\n// parseConfig extracts and validates RSS configuration.\nfunc parseConfig(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 rss credentials: %w\", err)\n\t}\n\tif urls := feedURLsFromSettings(config.Settings); urls != \"\" {\n\t\tcfg.FeedURLs = urls\n\t}\n\tif len(cfg.feedURLList()) == 0 {\n\t\treturn nil, fmt.Errorf(\"%w: feed_urls is required\", datasource.ErrInvalidCredentials)\n\t}\n\treturn &cfg, nil\n}\n\nfunc feedURLsFromSettings(settings map[string]interface{}) string {\n\tif len(settings) == 0 {\n\t\treturn \"\"\n\t}\n\traw, ok := settings[\"feed_urls\"]\n\tif !ok {\n\t\treturn \"\"\n\t}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/datasource/connector/rss/types.go#L47-L83","documentation":"After marshaling, parseConfig unmarshals the credential bytes into the RSS Config struct. A failure here means the stored credentials are not valid JSON or do not decode cleanly into Config. This typically indicates a corrupt or wrong-shaped credentials payload persisted for the datasource.","triggerScenarios":"The datasource's credentials value is not valid JSON (corrupt row, binary data, partially written update), or the unmarshal cannot populate the Config struct from the JSON value.","commonSituations":"A migration changed the credentials schema; an operator pasted YAML/TOML into the credentials field instead of JSON; a database write was truncated; an old datasource stored credentials in a now-unsupported shape.","solutions":["Inspect the stored credentials JSON for the datasource and re-save it as a valid JSON object with a feed_urls field.","Re-author/re-configure the datasource through the UI so the service re-serializes credentials correctly.","Validate the JSON with a parser (jq/JSON lint) before saving; fix syntax errors.","Check for migrations that changed the credentials schema and migrate old records."],"exampleFix":"// before (stored credentials)\nfeed_urls: https://a.example/rss, https://b.example/rss   // not JSON\n// after\n{\"feed_urls\": \"https://a.example/rss, https://b.example/rss\"}","handlingStrategy":"validation","validationCode":"raw, _ := json.Marshal(config.Credentials)\nvar probe map[string]interface{}\nif err := json.Unmarshal(raw, &probe); err != nil {\n    return fmt.Errorf(\"stored credentials are not valid JSON: %w\", err)\n}","typeGuard":"func isJSONObject(b []byte) bool {\n    var v map[string]interface{}\n    return json.Unmarshal(b, &v) == nil\n}","tryCatchPattern":"cfg, err := parseConfig(config)\nif err != nil && strings.Contains(err.Error(), \"parse rss credentials\") {\n    // prompt user to re-configure the source\n    return err\n}","preventionTips":["Validate credentials JSON with a parser before persisting.","Never hand-edit credentials in the DB; use the configuration UI/API.","Add schema migrations for credential shape changes."],"tags":["go","json","credentials","rss"],"backgroundTag":"json-decode-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}