Mintplex-Labs/anything-llm · warning
Key cannot start with 'system.'
Error message
Key cannot start with 'system.'
What it means
Keys starting with 'system.' are reserved for the system-defined expansion namespace; custom variables may not shadow them. As with 'user.', a dotted key is rejected earlier by the character-set check, so this guard is defense-in-depth for the reserved namespace in the current validation order.
Solutions
- Pick a key outside the reserved namespace, e.g. 'app_version' instead of 'system.version'
- Use underscores for pseudo-namespacing: 'system_date' still starts with 'system_' not 'system.' and passes - prefer a clearer distinct name like 'runtime_date'
- Document reserved prefixes for your team so they are not attempted
Example fix
// before
SystemPromptVariables.create({ key: 'system.date', value: '2026-01-01' }); // reserved prefix
// after
SystemPromptVariables.create({ key: 'fallback_date', value: '2026-01-01' }); Defensive patterns
Strategy: validation
Validate before calling
const RESERVED_PREFIXES = ['user.', 'system.'];
function usesReservedPrefix(key) {
return typeof key === 'string' && RESERVED_PREFIXES.some((p) => key.startsWith(p));
}
if (usesReservedPrefix(key)) {
return res.status(400).json({ error: 'Keys may not start with user. or system.' });
} Try / catch
try {
await SystemPromptVariables.create({ key, value });
} catch (err) {
if (/cannot start with/.test(err.message)) {
return res.status(400).json({ error: 'Reserved namespace; rename the key' });
}
throw err;
} Prevention
- Never copy a built-in {{system.*}} placeholder verbatim as a custom key
- Namespace custom keys with underscores and a distinct project prefix
- Share the reserved-prefix list with anyone authoring prompt templates
When it happens
Trigger: Attempting to define 'system.prompt' or 'system.date' as a custom variable; copying a built-in template placeholder verbatim as a key when creating a variable.
Common situations: Trying to override built-in system expansion values; importing variable sets from other tools that use dotted system namespaces.
Related errors
- Key cannot start with 'user.'
- Key is required
- Key must be a string
- Key must be at least 3 characters
- Key must be less than 255 characters
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/9055d63728da0b1e.
Report an issue: GitHub.
Appendix: 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 3aec848f28)