influxdata/influxdb · error · WriteError::Fail
Cannot write
Error message
Cannot write: {0} What it means
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.
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
Defensive patterns
Strategy: try-catch
Validate before calling
def validate_lp(lines, expected_types):
for line in lines:
if not line or ' ' not in line:
raise ValueError(f'invalid line protocol: {line!r}') Try / catch
try:
api.write_to_database('mydb', line_protocol)
except Exception as e:
# inspect str(e); 'Cannot write: ...' wraps the underlying cause
logger.error(f'write failed: {e}')
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- internal writes are not supported by the write accumulator
- line protocol parse failed
- cannot write to soft-deleted database
- column ' ' ( ) is not defined in table ' ' of database ' '…
- column type mismatch for column
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/69f6b3fecfa18664.
Report an issue: GitHub.
Appendix: source
Thrown at influxdb3_py_api/src/write.rs:54
_ingest_time: Time,
_no_sync: bool,
) -> Result<(), WriteError> {
match target {
WriteTarget::User(database) if database.as_str() == INTERNAL_DB_NAME => {
Err(WriteError::InternalWriteUnsupported)
}
WriteTarget::User(database) => {
self.push(database.as_str().to_owned(), lp.to_owned());
Ok(())
}
WriteTarget::Internal => Err(WriteError::InternalWriteUnsupported),
}
}
}
#[derive(Debug, Error)]
pub enum WriteError {
#[error("Cannot write: {0}")]
Fail(Box<dyn std::error::Error + Send + Sync>),
#[error("internal writes are not supported by the write accumulator")]
InternalWriteUnsupported,
}
#[derive(Debug, Clone)]
pub enum WriteTarget {
/// Write into a user database.
User(DatabaseName),
/// Write into the one system-managed internal database.
Internal,
}
#[async_trait]
pub trait WriteEndpoint: std::fmt::Debug + Send + Sync + 'static {
async fn write_lp(
&self,View on GitHub (pinned to 06200ef96b)