affaan-m/ECC · error · Error
${label} must be a non-empty string.
Error message
${label} must be a non-empty string. What it means
Thrown by asNonEmptyString(), the shared validator used for nearly every memory-vault string field (title, kind, scope, tags, etc.). It rejects values that are not strings or that are empty/whitespace-only after trimming. The label parameter identifies which field failed.
Source
Thrown at scripts/lib/memory-vault-format.js:79
function hasUnsafeControlCharacters(value, allowBodyWhitespace = false) {
return Array.from(value).some(character => {
const codePoint = character.codePointAt(0);
const allowedWhitespace = allowBodyWhitespace
&& (codePoint === 0x09 || codePoint === 0x0a || codePoint === 0x0d);
const isControl = (codePoint <= 0x1f && !allowedWhitespace)
|| (codePoint >= 0x7f && codePoint <= 0x9f);
const isBidirectionalFormatting = (
(codePoint >= 0x202a && codePoint <= 0x202e)
|| (codePoint >= 0x2066 && codePoint <= 0x2069)
);
return isControl || isBidirectionalFormatting;
});
}
function asNonEmptyString(value, label, maxChars = 10_000) {
if (typeof value !== 'string' || value.trim().length === 0) {
throw new Error(`${label} must be a non-empty string.`);
}
const normalized = value.trim();
if (normalized.length > maxChars) {
throw new Error(`${label} is too long (maximum ${maxChars} characters).`);
}
if (hasUnsafeControlCharacters(normalized)) {
throw new Error(`${label} must not contain control or bidirectional formatting characters.`);
}
return normalized;
}
function validateEnum(value, allowed, label) {
const normalized = asNonEmptyString(value, label, 64);
if (!allowed.includes(normalized)) {
throw new Error(`${label} must be one of: ${allowed.join(', ')}.`);
}
return normalized;
}View on GitHub (pinned to 01e15490f0)
Solutions
- Inspect the label in the error to find which field is empty.
- Provide a non-empty trimmed string for that field.
- If the field is genuinely optional in your flow, omit it from the memory document rather than passing an empty string.
Example fix
// before
asNonEmptyString('', 'title');
// after
asNonEmptyString('Auth decision for v2 API', 'title'); Defensive patterns
Strategy: type-guard
Validate before calling
function isNonEmptyString(value) {
return typeof value === 'string' && value.trim().length > 0;
}
if (!isNonEmptyString(title)) {
throw new Error('title is required and must be a non-empty string.');
} Type guard
function isNonEmptyString(value) {
return typeof value === 'string' && value.trim().length > 0;
} Try / catch
try {
result = asNonEmptyString(value, label);
} catch (e) {
if (/must be a non-empty string/.test(e.message)) return null; // treat as missing
throw e;
} Prevention
- Trim and check user input before submission.
- Make required fields explicit in the form/UI so users cannot submit empty.
- Differentiate optional (omit key) from required (must be non-empty) in your schema.
When it happens
Trigger: Passing undefined for a required field, an empty string, a number where a string is expected, or a string of only spaces/tabs/newlines.
Common situations: Reading frontmatter with a missing key; user input that was not sanitized; a generator that omits optional-looking but required fields.
Related errors
- ${label} is too long (maximum ${maxChars} characters).
- ${label} must be a lowercase letters/numbers slug.
- memory id must match mem_<lowercase-id> and cannot contain a
- ${label} must be an array.
- Invalid format: ${parsed.format}. Use text, json, or markdow
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/6035cf848a6f7cab.
Report an issue: GitHub.