nexu-io/open-design · error · Error
memory entry requires `name` and a valid `type`
Error message
memory entry requires `name` and a valid `type`
What it means
upsertMemoryEntry requires a non-empty name string and a type that is in the valid set. Valid types are defined by MEMORY_TYPES from packages/contracts: 'profile', 'user', 'feedback', 'project', 'reference', 'rule'. The isValidType check rejects anything else.
Source
Thrown at apps/daemon/src/memory.ts:510
return upsertMemoryEntry(dataDir, {
id,
name:
typeof patch?.name === 'string' && patch.name.trim()
? patch.name
: current.name,
description:
typeof patch?.description === 'string'
? patch.description
: current.description,
type: nextType,
body: typeof patch?.body === 'string' ? patch.body : current.body,
});
}
export async function upsertMemoryEntry(dataDir, input, options) {
const { name, description, type, body } = input || {};
if (!name || !isValidType(type)) {
throw new Error('memory entry requires `name` and a valid `type`');
}
const id = input?.id && /^[a-z0-9_]+$/.test(input.id)
? input.id
: deriveMemoryId(type, name);
await ensureDir(memoryDir(dataDir));
await fsp.writeFile(
entryPath(dataDir, id),
renderEntryFile(name, description, type, body, options?.source ?? 'manual'),
);
await ensureIndexHasEntry(dataDir, id, name, description);
const entry = await readMemoryEntry(dataDir, id);
if (!entry) throw new Error('failed to read memory entry after write');
if (!options?.silent) {
emitChange({
kind: 'upsert',
id: entry.id,
name: entry.name,
description: entry.description,View on GitHub (pinned to 5be4028344)
Solutions
- Provide a non-empty name string in the input
- Set type to exactly one of: 'profile', 'user', 'feedback', 'project', 'reference', 'rule'
- Validate the type against MEMORY_TYPES before calling upsertMemoryEntry
Example fix
// before — invalid type 'note'
upsertMemoryEntry(dataDir, { name: 'My note', type: 'note', body: '...' });
// after — valid type 'reference'
upsertMemoryEntry(dataDir, { name: 'My note', type: 'reference', body: '...' }); Defensive patterns
Strategy: validation
Validate before calling
import { MEMORY_TYPES } from '@open-design/contracts';
const VALID_MEMORY_TYPES = new Set(MEMORY_TYPES);
function assertValidMemoryInput(input) {
if (!input?.name || typeof input.name !== 'string' || !input.name.trim()) {
throw new Error('Memory entry requires a non-empty name');
}
if (!VALID_MEMORY_TYPES.has(input.type)) {
throw new Error(`Invalid memory type: ${input.type}. Valid types: ${[...VALID_MEMORY_TYPES].join(', ')}`);
}
} Type guard
import { MEMORY_TYPES } from '@open-design/contracts';
type MemoryType = typeof MEMORY_TYPES[number];
function isValidMemoryType(type: unknown): type is MemoryType {
return typeof type === 'string' && (MEMORY_TYPES as readonly string[]).includes(type);
} Prevention
- Always validate name and type before calling upsertMemoryEntry
- Reference MEMORY_TYPES from packages/contracts to stay in sync with the valid type set
- Use lowercase type values — the check is case-sensitive
- Make UI forms require a name field before submission is enabled
When it happens
Trigger: Calling upsert with an empty/undefined/null name; calling upsert with a type not in the valid set (e.g. 'note', 'memory', 'custom', 'tag'); type has wrong casing (e.g. 'User' instead of 'user').
Common situations: UI form submitted without a name field; API caller sends an outdated or custom type value; type field has a typo; caller assumes arbitrary type strings are accepted.
Related errors
- delete proposal requires targetRef
- invalid memory id
- memory tree folders are derived and cannot be edited
- invalid JSON in ${filePath}: ${message}
- ${filePath} must contain a JSON object
AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12).
Data as JSON: /api/errors/f45e5b22de78a9bb.
Report an issue: GitHub.