Mintplex-Labs/anything-llm · error · Error
Key cannot start with 'system.'
Error message
Key cannot start with 'system.'
What it means
Thrown by SystemPromptVariables._checkVariableKey when key starts with 'system.'. The 'system.' namespace is reserved for built-in system variables supplied by the platform during prompt expansion, so a user-defined static variable with that prefix is rejected to avoid collisions.
Source
Thrown at server/models/systemPromptVariables.js:367
/**
* Internal function to check if a variable key is valid
* @param {string} key
* @param {boolean} checkExisting
* @returns {Promise<boolean>}
*/
_checkVariableKey: async function (key = null, checkExisting = true) {
if (!key) throw new Error("Key is required");
if (typeof key !== "string") throw new Error("Key must be a string");
if (!/^[a-zA-Z0-9_]+$/.test(key))
throw new Error("Key must contain only letters, numbers and underscores");
if (key.length > 255)
throw new Error("Key must be less than 255 characters");
if (key.length < 3) throw new Error("Key must be at least 3 characters");
if (key.startsWith("user."))
throw new Error("Key cannot start with 'user.'");
if (key.startsWith("system."))
throw new Error("Key cannot start with 'system.'");
if (checkExisting && (await this.get(key)) !== null)
throw new Error("System prompt variable with this key already exists");
return true;
},
};
module.exports = { SystemPromptVariables };
View on GitHub (pinned to 526360e320)
Solutions
- Rename the key to drop the 'system.' prefix (e.g. 'system_context' or 'app_context').
- Use the built-in 'system.*' variables instead of redefining them as static entries.
Example fix
// before
SystemPromptVariables.create({ key: 'system.context', value: '...' });
// after
SystemPromptVariables.create({ key: 'app_context', value: '...' }); Defensive patterns
Strategy: validation
Validate before calling
if (typeof key === 'string' && key.startsWith('system.')) {
throw new Error("Keys cannot use the reserved 'system.' prefix");
} Type guard
const isNonReservedKey = (k) => typeof k === 'string' && !k.startsWith('system.') && !k.startsWith('user.'); Prevention
- Surface reserved-prefix rules next to the key field.
- Reuse the built-in system.* variables instead of redefining them.
When it happens
Trigger: POST/PUT /system/prompt-variables with a key like 'system.foo', 'system.context', or 'system.date'.
Common situations: An admin assumes 'system.' is the conventional prefix for platform-level variables and tries to register one.
Related errors
- Key cannot start with 'user.'
- Key is required
- Key must contain only letters, numbers and underscores
- Key must be less than 255 characters
- System prompt variable with this key already exists
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/9055d63728da0b1e.
Report an issue: GitHub.