{"record":{"id":"8f9cdcc5a620ecb0","repo":"influxdata/influxdb","slug":"internal-writes-are-not-supported-by-the-write-accumulator","errorCode":null,"errorMessage":"internal writes are not supported by the write accumulator","messagePattern":"internal writes are not supported by the write accumulator","errorType":"error_code","errorClass":"WriteError::InternalWriteUnsupported","httpStatus":null,"severity":"error","filePath":"influxdb3_py_api/src/write.rs","lineNumber":57,"sourceCode":"        match target {\n            WriteTarget::User(database) if database.as_str() == INTERNAL_DB_NAME => {\n                Err(WriteError::InternalWriteUnsupported)\n            }\n            WriteTarget::User(database) => {\n                self.push(database.as_str().to_owned(), lp.to_owned());\n                Ok(())\n            }\n            WriteTarget::Internal => Err(WriteError::InternalWriteUnsupported),\n        }\n    }\n}\n\n#[derive(Debug, Error)]\npub enum WriteError {\n    #[error(\"Cannot write: {0}\")]\n    Fail(Box<dyn std::error::Error + Send + Sync>),\n\n    #[error(\"internal writes are not supported by the write accumulator\")]\n    InternalWriteUnsupported,\n}\n\n#[derive(Debug, Clone)]\npub enum WriteTarget {\n    /// Write into a user database.\n    User(DatabaseName),\n    /// Write into the one system-managed internal database.\n    Internal,\n}\n\n#[async_trait]\npub trait WriteEndpoint: std::fmt::Debug + Send + Sync + 'static {\n    async fn write_lp(\n        &self,\n        target: WriteTarget,\n        lp: &str,\n        ingest_time: Time,","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_py_api/src/write.rs#L39-L75","documentation":"WriteError::InternalWriteUnsupported is returned by the plugin WriteAccumulator's write_lp when a plugin attempts to write to the internal/system database (WriteTarget::Internal, or a User target naming the internal DB name) during plugin execution. Plugins may only accumulate writes into user databases; internal database writes are not supported in this context.","triggerScenarios":"A Python plugin calls the write endpoint (api.write_to_database or similar) targeting the internal database name (INTERNAL_DB_NAME), or the write machinery routes the write to WriteTarget::Internal while the plugin WriteAccumulator is the endpoint.","commonSituations":"Plugin code dynamically computes the target database name and accidentally resolves to the system/internal database; a plugin written for a context that allowed internal writes is reused in a trigger/plugin context where the accumulator forbids them; hardcoding the internal DB name in plugin configuration.","solutions":["Change the plugin to write to a user database instead of the internal/system database","Check where the target database name is computed/configured and ensure it never equals the internal DB name","Move internal-metrics data to a dedicated user database if it must be written from a plugin","If internal writes are genuinely required, perform them outside plugin execution via the normal write path/CLI"],"exampleFix":"// before (plugin)\napi.write_to_database('_internal', line_protocol)\n// after (plugin)\napi.write_to_database('my_metrics_db', line_protocol)","handlingStrategy":"validation","validationCode":"INTERNAL_DB = '_internal'\n\ndef guard_target(db):\n    if not db or db == INTERNAL_DB:\n        raise ValueError(f'plugin writes to internal database {db!r} are not allowed')","typeGuard":"def is_user_db(name):\n    return isinstance(name, str) and len(name) > 0 and not name.startswith('_')","tryCatchPattern":"try:\n    api.write_to_database(target_db, line_protocol)\nexcept Exception as e:\n    if 'internal writes are not supported' in str(e):\n        target_db = 'fallback_user_db'\n        api.write_to_database(target_db, line_protocol)\n    else:\n        raise","preventionTips":["Never hardcode the internal/system database name as a plugin write target","Validate the computed target database name before calling the write endpoint","Use a dedicated user database for plugin-generated metrics"],"tags":["write","internal-database","influxdb3","plugin-execution"],"backgroundTag":"database-write-failed","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}