{"record":{"id":"a7124f9e771152c4","repo":"influxdata/influxdb","slug":"invalid-character-in-database-or-rp-name-must-be-ascii","errorCode":null,"errorMessage":"invalid character in database or rp name: must be ASCII, containing only letters, numbers, underscores, or hyphens","messagePattern":"invalid character in database or rp name: must be ASCII, containing only letters, numbers, underscores, or hyphens","errorType":"validation","errorClass":"ValidateDbNameError","httpStatus":null,"severity":"error","filePath":"influxdb3_server/src/http.rs","lineNumber":2422,"sourceCode":"        }\n        last_char.replace(char);\n    }\n\n    if last_char.is_some_and(|c| c == '/') {\n        return Err(ValidateDbNameError::InvalidRetentionPolicy);\n    }\n\n    Ok(())\n}\n\n// v1 supports 255 chars for the database name and 255 chars for the\n// retention policy name; we support those combined with a forward slash so\n// 255*2+1.\nconst MAXIMUM_DATABASE_NAME_LENGTH: usize = 511;\n\n#[derive(Clone, Copy, Debug, thiserror::Error)]\npub enum ValidateDbNameError {\n    #[error(\n        \"invalid character in database or rp name: must be ASCII, \\\n        containing only letters, numbers, underscores, or hyphens\"\n    )]\n    InvalidChar,\n    #[error(\"db name did not start with a number or letter\")]\n    InvalidStartChar,\n    #[error(\n        \"db name with invalid retention policy, if providing a \\\n        retention policy name, must be of form '<db_name>/<rp_name>'\"\n    )]\n    InvalidRetentionPolicy,\n    #[error(\"db name cannot be empty\")]\n    Empty,\n    #[error(\"db name too long: max {}\", MAXIMUM_DATABASE_NAME_LENGTH)]\n    NameTooLong,\n}\n\nasync fn record_batch_stream_to_body(","sourceCodeStart":2404,"sourceCodeEnd":2440,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_server/src/http.rs#L2404-L2440","documentation":"Variant `InvalidChar` of `ValidateDbNameError` in influxdb3_server/src/http.rs. The requested database (or retention policy) name contains a character outside the allowed set: ASCII letters, numbers, underscores, and hyphens. Names are validated before any database is created or written to.","triggerScenarios":"Calling write/query endpoints with `?db=` or db/rp path values containing spaces, dots, slashes, Unicode, or symbols (e.g. `db=my data`, `db=my.db`).","commonSituations":"Deriving database names from user input or filenames; using dots like in v1 'db.rp' notation without the slash form; internationalized names; templated names with unescaped variables.","solutions":["Rename the target to only [a-zA-Z0-9_-] characters before sending the request","If combining db and retention policy, use the `<db_name>/<rp_name>` form with a forward slash","Sanitize/encode the db parameter on the client side with a validation regex before calling the API"],"exampleFix":"// before\ncurl 'host/api/v3/write?db=my data'\n// after\ncurl 'host/api/v3/write?db=my_data'","handlingStrategy":"validation","validationCode":"const DB_RE = /^[a-zA-Z0-9_-]+$/;\nfunction validateDbName(db) {\n  if (!DB_RE.test(db)) throw new Error(`invalid db/rp name '${db}': use only ASCII letters, numbers, _ and -`);\n}","typeGuard":"const isValidDbName = (db) => typeof db === 'string' && /^[a-zA-Z0-9_-]+$/.test(db);","tryCatchPattern":"try {\n  return await api.write(db, data);\n} catch (e) {\n  if (String(e.message).includes('invalid character in database or rp name')) {\n    throw new ValidationError(`sanitize db name: ${db}`);\n  }\n  throw e;\n}","preventionTips":["Sanitize user-derived database names with the allowed-character regex before every call","Use the <db>/<rp> slash form when a retention policy is included"],"tags":["database","naming","validation","write-api"],"backgroundTag":"invalid-identifier-format","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"}