diegosouzapw/OmniRoute · error · Error

error

Error message

error

What it means

Generic GraphQL error propagation in PromptQL's gql helper: the HTTP response was OK and valid JSON, but the payload contained a non-empty errors array, meaning the query executed and was rejected server-side (bad query, missing field, permission, or resolver failure).

Solutions

  1. Inspect json.errors messages to fix the query shape or variables
  2. Handle partial data alongside errors when the API returns both
  3. Distinguish authorization errors from query validation errors
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at open-sse/executors/promptql.ts:258 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/024e90cfa9b01990. Report an issue: GitHub.

Appendix: source

Thrown at open-sse/executors/promptql.ts:258

      origin: "https://prompt.ql.app",
      referer: "https://prompt.ql.app/",
      "user-agent": USER_AGENT,
    },
    body: JSON.stringify({ query, variables, operationName }),
    signal: signal ?? undefined,
  });
  const text = await res.text();
  let json: { data?: T; errors?: Array<{ message?: string }> };
  try {
    json = JSON.parse(text) as typeof json;
  } catch {
    throw new Error(`Non-JSON GraphQL HTTP ${res.status}: ${text.slice(0, 300)}`);
  }
  if (!res.ok) {
    throw new Error(`GraphQL HTTP ${res.status}: ${text.slice(0, 400)}`);
  }
  if (json.errors?.length) {
    throw new Error(json.errors.map((e) => e.message || "error").join("; "));
  }
  return json.data as T;
}

/**
 * Best-effort JWT refresh. Requires browser session cookies (credentials: include
 * in the SPA). Headless callers must store those cookies in providerSpecificData.cookie.
 * **Not fully verified in production** — see PR notes.
 */
export async function tryRefreshPromptQlToken(opts: {
  projectId: string;
  cookie?: string;
  signal?: AbortSignal | null;
}): Promise<string | null> {
  if (!opts.cookie || !opts.projectId) return null;
  try {
    const res = await fetch(TOKEN_REFRESH_URL, {
      method: "POST",

View on GitHub (pinned to a179ffed5b)