{"record":{"id":"1b3d76bc65f3b5a8","repo":"quickwit-oss/quickwit","slug":"index-id-in-config-file-does-not-match-index-id","errorCode":null,"errorMessage":"`index_id` in config file does not match index_id from query path","messagePattern":"`index_id` in config file does not match index_id from query path","errorType":"validation","errorClass":"IndexServiceError","httpStatus":400,"severity":"error","filePath":"quickwit/quickwit-serve/src/index_api/index_resource.rs","lineNumber":363,"sourceCode":"    node_config: Arc<NodeConfig>,\n) -> Result<IndexMetadata, IndexServiceError> {\n    info!(index_id = %target_index_id, \"update-index\");\n\n    let metastore = index_service.metastore();\n    let index_metadata_request = IndexMetadataRequest::for_index_id(target_index_id.to_string());\n    let current_index_metadata_res = metastore.index_metadata(index_metadata_request).await;\n\n    let current_index_metadata_ser = match current_index_metadata_res {\n        Ok(index_metadata) => index_metadata,\n        Err(MetastoreError::NotFound(_)) if query_params.create => {\n            let index_config = quickwit_config::load_index_config_from_user_config(\n                config_format,\n                &index_config_bytes,\n                &node_config.default_index_root_uri,\n            )\n            .map_err(IndexServiceError::InvalidConfig)?;\n            if index_config.index_id != target_index_id {\n                return Err(IndexServiceError::InvalidConfig(anyhow::anyhow!(\n                    \"`index_id` in config file does not match index_id from query path\"\n                )));\n            }\n            info!(index_id = %index_config.index_id, \"create-index-on-update\");\n            match index_service.create_index(index_config, false).await {\n                Err(IndexServiceError::Metastore(MetastoreError::AlreadyExists(_))) => {\n                    // If the index was created just after we tried to update it, try to update as\n                    // if nothing happened. But if it gets deleted again before we update it, just\n                    // error out\n                    let index_metadata_request =\n                        IndexMetadataRequest::for_index_id(target_index_id.to_string());\n                    metastore.index_metadata(index_metadata_request).await?\n                }\n                other => return other,\n            }\n        }\n        Err(e) => return Err(e.into()),\n    };","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-serve/src/index_api/index_resource.rs#L345-L381","documentation":"On the update-index REST endpoint, if the request includes an index config file whose index_id differs from the index_id given in the URL path, the endpoint refuses to proceed. It prevents silently creating or updating an index under a different identity than specified in the path.","triggerScenarios":"PUT /indexes/{index_id} (update_index) with a config body whose index_id does not equal the {index_id} path parameter and where the index does not yet exist (create-on-update path).","commonSituations":"Reusing one YAML config file against multiple index endpoints; renamed index in config but not in the URL (or vice versa); templated automation scripts passing a generic config.","solutions":["Make the index_id in the config file match the index_id in the request path.","Or omit/adjust the path index_id so it corresponds to the config's index_id.","In automation, template the config file's index_id from the same variable used to build the URL."],"exampleFix":"// before: PUT /indexes/my-index with config containing\nversion: 0.8\nindex_id: old-index\n// after\nversion: 0.8\nindex_id: my-index","handlingStrategy":"validation","validationCode":"fn assert_index_id_match(path_index_id: &str, config: &serde_yaml::Value) -> Result<(), String> {\n    let cfg_id = config[\"index_id\"].as_str().ok_or(\"missing index_id in config\")?;\n    if cfg_id != path_index_id { Err(format!(\"config index_id `{cfg_id}` != path `{path_index_id}`\")) } else { Ok(()) }\n}","typeGuard":null,"tryCatchPattern":"match client.update_index(index_id, config_bytes).await {\n    Err(e) if e.to_string().contains(\"does not match index_id from query path\") => {\n        Err(anyhow!(\"fix index_id in config to match path `{index_id}`\"))\n    }\n    r => r,\n}","preventionTips":["Generate config files with index_id templated from the same variable used in the URL","Never reuse one config file for multiple index endpoints","Diff config index_id against the path in CI before deployment"],"tags":["rust","rest-api","index-config","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"}