{"record":{"id":"69f6b3fecfa18664","repo":"influxdata/influxdb","slug":"cannot-write-0","errorCode":null,"errorMessage":"Cannot write: {0}","messagePattern":"Cannot write: (.+?)","errorType":"error_code","errorClass":"WriteError::Fail","httpStatus":null,"severity":"error","filePath":"influxdb3_py_api/src/write.rs","lineNumber":54,"sourceCode":"        _ingest_time: Time,\n        _no_sync: bool,\n    ) -> Result<(), WriteError> {\n        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,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_py_api/src/write.rs#L36-L72","documentation":"WriteError::Fail is the generic variant of the write error enum used by WriteEndpoint implementations in the Python plugin API; it wraps any underlying write failure as 'Cannot write: {cause}'. It indicates the requested line protocol write could not be performed, with the concrete cause boxed inside the error.","triggerScenarios":"Any write_lp call on a WriteEndpoint whose underlying storage/HTTP write fails, with the inner error (network failure, invalid line protocol, auth failure, database not found) preserved in the message.","commonSituations":"Plugin writes line protocol with schema/type conflicts against an existing table; write target database does not exist; network or auth failure when writing via HTTP to an InfluxDB endpoint; malformed line protocol rejected by the server.","solutions":["Read the inner cause after 'Cannot write: ' to identify the actual failure and fix that first","Validate line protocol syntax and field types against the target table schema before writing","Confirm the target database exists (create it if needed) and that credentials/permissions allow writes","Check network connectivity and endpoint configuration if the write goes over HTTP"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"def validate_lp(lines, expected_types):\n    for line in lines:\n        if not line or ' ' not in line:\n            raise ValueError(f'invalid line protocol: {line!r}')","typeGuard":null,"tryCatchPattern":"try:\n    api.write_to_database('mydb', line_protocol)\nexcept Exception as e:\n    # inspect str(e); 'Cannot write: ...' wraps the underlying cause\n    logger.error(f'write failed: {e}')\n    raise","preventionTips":["Validate line protocol syntax and field types against the table schema before writing","Ensure the target database exists and credentials have write permission","Keep the inner cause of 'Cannot write: ...' in logs to diagnose the root failure"],"tags":["write","line-protocol","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"}