danielmiessler/Fabric · error · Error
response.error
Error message
response.error
What it means
createStorageAPI().get() unwraps the API envelope: api.fetch returns { data, error } and get() throws when error is truthy. This is an application-level error relayed verbatim from the backend, not an HTTP failure — fetch already succeeded with 2xx.
Source
Thrown at web/src/lib/api/base.ts:63
const reader = response.body?.getReader();
if (!reader) throw new Error('Response body is null');
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
yield decoder.decode(value);
if (done) break;
}
}
};
export function createStorageAPI<T extends StorageEntity>(entityType: string) {
return {
async get(name: string): Promise<T> {
const response = await api.fetch<T>(`/${entityType}/${name}`);
if (response.error) throw new Error(response.error);
return response.data as T;
},
async getNames(): Promise<string[]> {
const response = await api.fetch<string[]>(`/${entityType}/names`);
if (response.error) throw new Error(response.error);
return response.data as [];
},
async delete(name: string): Promise<void> {
const response = await api.fetch(`/${entityType}/${name}`, { method: 'DELETE' });
if (response.error) throw new Error(response.error);
},
async exists(name: string): Promise<boolean> {
const response = await api.fetch<boolean>(`/${entityType}/exists/${name}`);
if (response.error) throw new Error(response.error);
return response.data as boolean;View on GitHub (pinned to 338b89cfe9)
Solutions
- Confirm the entity actually exists via the exists() method before assuming corruption
- Check the backend handler for /<entityType>/:name to see what conditions produce this error string
- URL-encode names with encodeURIComponent if the name may contain slashes or special characters
Defensive patterns
Strategy: try-catch
Validate before calling
if (!(await storageApi.exists(name))) {
throw new Error(`Entity '${name}' does not exist; nothing to get`);
} Type guard
function isEnvelopeError(e: unknown): e is Error {
return e instanceof Error && e.message.length > 0 && !e.message.startsWith('HTTP');
} Try / catch
try {
return await storageApi.get(name);
} catch (e) {
if (e instanceof Error && /not found/i.test(e.message)) return undefined; // typed miss
throw e;
} Prevention
- Check exists() (guarded) before get() when a miss is expected
- Keep entity lists fresh before acting on user selections
- URL-encode all name path segments
When it happens
Trigger: GET /<entityType>/<name> returning JSON with a non-null error field: entity not found, invalid name, or a server-side read failure serialized into the envelope.
Common situations: Requesting a pattern/session/note deleted by another tab or process; name containing characters the backend rejects; storage backend (disk/DB) unavailable so the handler answers with an error envelope instead of a status code.
Related errors
- data.error
- HTTP error! status: ${response.status}
- Invalid response format: missing vendors data
- HTTP_ERROR
- errorData.error || `HTTP error! status: ${response.status}`
AI-assisted analysis of danielmiessler/Fabric@338b89cfe9 (2026-08-15).
Data as JSON: /api/errors/fe170f1202fa4f40.
Report an issue: GitHub.