janhq/jan · error · VectorDBError
Invalid input: {0}
Error message
Invalid input: {0} What it means
The InvalidInput variant of VectorDBError is thrown when a caller passes data that fails pre-execution validation (e.g. wrong vector dimensionality, empty collection name, malformed IDs) before any SQL is run. It is a manual variant — unlike DatabaseError which auto-converts from rusqlite::Error and serde_json::Error via From impls, InvalidInput must be explicitly constructed by command code. The {0} placeholder is the human-readable detail string supplied at construction time.
Source
Thrown at src-tauri/plugins/tauri-plugin-vector-db/src/error.rs:8
use serde::{Deserialize, Serialize};
#[derive(Debug, thiserror::Error, Serialize, Deserialize)]
pub enum VectorDBError {
#[error("Database error: {0}")]
DatabaseError(String),
#[error("Invalid input: {0}")]
InvalidInput(String),
}
impl From<rusqlite::Error> for VectorDBError {
fn from(err: rusqlite::Error) -> Self {
VectorDBError::DatabaseError(err.to_string())
}
}
impl From<serde_json::Error> for VectorDBError {
fn from(err: serde_json::Error) -> Self {
VectorDBError::DatabaseError(err.to_string())
}
}
View on GitHub (pinned to fad3f12a14)
Solutions
- Check the collection's dimension before inserting and ensure the incoming vector length matches it exactly.
- Validate collection names are non-empty alphanumeric strings before calling the API.
- Log the full error string {0} — it contains the specific field and expected value.
- Recreate the collection with the correct dimension if the embedding model changed.
Example fix
// before
store.insert("docs", vec![0.1, 0.2]).await?; // dim mismatch if collection is 1536
// after
let dim = store.collection_dimension("docs").await?;
if embedding.len() != dim {
return Err(VectorDBError::InvalidInput(format!(
"vector dim {} != collection dim {}", embedding.len(), dim
)));
}
store.insert("docs", embedding).await?; Defensive patterns
Strategy: validation
Validate before calling
// Before calling vector-db insert/search, validate dimensions
function validateVector(vector: number[], expectedDim: number): string | null {
if (!Array.isArray(vector) || vector.length === 0) return 'vector is empty';
if (vector.length !== expectedDim) return `dim ${vector.length} != expected ${expectedDim}`;
if (vector.some(v => typeof v !== 'number' || Number.isNaN(v))) return 'vector contains non-numeric values';
return null;
}
const err = validateVector(embedding, collectionDim);
if (err) { toast.error(`Invalid input: ${err}`); return; } Type guard
function isValidVectorInput(v: unknown, dim: number): v is number[] {
return Array.isArray(v) && v.length === dim && v.every(x => typeof x === 'number' && !Number.isNaN(x));
}
function isValidCollectionName(name: string): boolean {
return /^[a-zA-Z0-9_-]{1,128}$/.test(name);
} Try / catch
match result {
Ok(data) => /* use data */,
Err(VectorDBError::InvalidInput(msg)) => {
log::warn!("Validation rejected: {msg}");
// surface to user as a 400-style error
}
Err(VectorDBError::DatabaseError(msg)) => {
log::error!("DB error: {msg}");
// surface as 500-style error
}
} Prevention
- Always validate vector dimensionality against the collection schema before insert.
- Sanitize collection names to alphanumeric + underscore/hyphen.
- Write integration tests that exercise the dimension-mismatch path.
- Log the expected vs actual dimension in the InvalidInput message.
When it happens
Trigger: Calling vector-db insert/upsert/search commands with a vector whose dimension count does not match the collection's configured dimension. Passing an empty or whitespace-only collection name. Supplying a vector ID that is not a valid string or integer. Providing a filter/metadata payload that fails schema validation.
Common situations: Switching embedding models without recreating the collection (384-dim model into a 1536-dim collection). Copy-pasting a dimension from a different provider's docs. Frontend sending a stale/null ID after a race condition. Version mismatch between the plugin and the embedding backend.
Related errors
- Invalid backend string: ${targetBackendString} supplied to u
- Invalid backend string format: "${targetBackendString}". Exp
- Invalid path or file ${path}
- Failed to parse archive name: ${archiveName}. Expected forma
- Invalid backend archive name: ${archiveName}
AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12).
Data as JSON: /api/errors/3b4cfab4a42aad7c.
Report an issue: GitHub.