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

  1. Confirm the entity actually exists via the exists() method before assuming corruption
  2. Check the backend handler for /<entityType>/:name to see what conditions produce this error string
  3. 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

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


AI-assisted analysis of danielmiessler/Fabric@338b89cfe9 (2026-08-15). Data as JSON: /api/errors/fe170f1202fa4f40. Report an issue: GitHub.