{"record":{"id":"4ebd3b2fe03a7e31","repo":"quickwit-oss/quickwit","slug":"source-id-in-config-file-does-not-match-source-i","errorCode":null,"errorMessage":"`source_id` in config file does not match source_id from query path","messagePattern":"`source_id` in config file does not match source_id from query path","errorType":"validation","errorClass":"IndexServiceError","httpStatus":400,"severity":"error","filePath":"quickwit/quickwit-serve/src/index_api/source_resource.rs","lineNumber":171,"sourceCode":"    config_format: ConfigFormat,\n    query_params: UpdateQueryParams,\n    source_config_bytes: Bytes,\n    mut index_service: IndexService,\n) -> Result<SourceConfig, IndexServiceError> {\n    let index_metadata_request = IndexMetadataRequest::for_index_id(index_id.to_string());\n    let mut current_index_metadata = index_service\n        .metastore()\n        .index_metadata(index_metadata_request)\n        .await?\n        .deserialize_index_metadata()?;\n    let current_source_config = match current_index_metadata.sources.remove(&source_id) {\n        Some(source_config) => source_config,\n        None if query_params.create => {\n            let source_config: SourceConfig =\n                load_source_config_from_user_config(config_format, &source_config_bytes)\n                    .map_err(IndexServiceError::InvalidConfig)?;\n            if source_config.source_id != source_id {\n                return Err(IndexServiceError::InvalidConfig(anyhow::anyhow!(\n                    \"`source_id` in config file does not match source_id from query path\"\n                )));\n            }\n            check_source_type(&source_config.source_params)?;\n            info!(index_id = %index_id, source_id = %source_config.source_id, \"create-source-on-update\");\n            // TODO handle already exists?\n            return index_service\n                .add_source(current_index_metadata.index_uid, source_config)\n                .await;\n        }\n        None => {\n            return Err(MetastoreError::NotFound(EntityKind::Source {\n                index_id: index_id.to_string(),\n                source_id,\n            })\n            .into());\n        }\n    };","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-serve/src/index_api/source_resource.rs#L153-L189","documentation":"On the update-source REST endpoint, when the source does not exist and create=true, the endpoint loads the source config from the request body and verifies its source_id matches the source_id in the URL path. A mismatch aborts with this error to prevent creating a source under a different identity than requested.","triggerScenarios":"PUT /indexes/{index_id}/sources/{source_id}?create=true with a source config body whose source_id differs from the {source_id} path parameter.","commonSituations":"Reusing a shared source config file across multiple sources; renaming a source in the path but not in the config; templating scripts where only one of the two identifiers was updated.","solutions":["Make source_id in the config file match the source_id in the request path.","Or issue the request against the path matching the config's source_id.","Template both the URL and config source_id from one variable in automation."],"exampleFix":"// before: PUT /indexes/my-index/sources/my-source with\nversion: 0.8\nsource_id: old-source\n// after\nversion: 0.8\nsource_id: my-source","handlingStrategy":"validation","validationCode":"fn assert_source_id_match(path_source_id: &str, config: &serde_yaml::Value) -> Result<(), String> {\n    let cfg_id = config[\"source_id\"].as_str().ok_or(\"missing source_id in config\")?;\n    if cfg_id != path_source_id { Err(format!(\"config source_id `{cfg_id}` != path `{path_source_id}`\")) } else { Ok(()) }\n}","typeGuard":null,"tryCatchPattern":"match client.update_source(index_id, source_id, config_bytes).await {\n    Err(e) if e.to_string().contains(\"does not match source_id from query path\") => {\n        Err(anyhow!(\"align config source_id with path `{source_id}`\"))\n    }\n    r => r,\n}","preventionTips":["Template source_id in both the URL and config from one variable","Validate config source_id before calling the API","Avoid copy-pasting source configs between source definitions"],"tags":["rust","rest-api","sources","mismatch"],"backgroundTag":"invalid-config-value","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}