continuedev/continue · error · Error

Failed to parse Greptile response: ${rawText}

Error message

Failed to parse Greptile response:
${rawText}

What it means

JSON.parse of the Greptile response body failed, so the expected { sources: [...] } shape couldn't be extracted. rawText is embedded in the message. Note the outer catch (error 28) replaces this with a generic message before it reaches callers, so inspect console.error output to see this one.

Source

Thrown at core/context/providers/GreptileContextProvider.ts:97

      );
      const rawText = await response.text();

      // Check for HTTP errors
      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }

      // Parse the response as JSON
      try {
        const json = JSON.parse(rawText);
        return json.sources.map((source: any) => ({
          description: source.filepath,
          content: `File: ${source.filepath}\nLines: ${source.linestart}-${source.lineend}\n\n${source.summary}`,
          name:
            (source.filepath.split("/").pop() ?? "").split("\\").pop() ?? "",
        }));
      } catch (jsonError) {
        throw new Error(`Failed to parse Greptile response:\n${rawText}`);
      }
    } catch (error) {
      console.error("Error getting context items from Greptile:", error);
      throw new Error("Error getting context items from Greptile");
    }
  }

  private getGreptileToken(): string | undefined {
    return this.options.GreptileToken || process.env.GREPTILE_AUTH_TOKEN;
  }

  private getGithubToken(): string | undefined {
    return this.options.GithubToken || process.env.GITHUB_TOKEN;
  }

  private async getWorkspaceDir(
    extras: ContextProviderExtras,
  ): Promise<string | null> {

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Look at the console.error('Error getting context items from Greptile:') output for the raw text
  2. Verify the Greptile API version/response shape with curl using the same payload
  3. Guard source fields before mapping and return [] on unexpected shapes

Example fix

// before
} catch (jsonError) {
  throw new Error(`Failed to parse Greptile response:\n${rawText}`);
}
// after
} catch (jsonError) {
  console.error('Greptile non-JSON response:', rawText?.slice(0, 300));
  return [];
}
Defensive patterns

Strategy: try-catch

Type guard

function isGreptileResponse(v: unknown): v is { sources: { filepath: string; linestart: number; lineend: number; summary: string }[] } {
  return !!v && Array.isArray((v as any).sources);
}

Try / catch

try { const json = JSON.parse(rawText); if (!isGreptileResponse(json)) return []; } catch { return []; }

Prevention

When it happens

Trigger: Greptile returns 200 with a non-JSON body (HTML error page, empty string, truncated stream) or a JSON shape where the sources mapping throws (e.g. sources undefined, source.filepath missing).

Common situations: Proxy or gateway intercepting the response; Greptile API contract change renaming fields; the .map callback throwing on unexpected data also lands here.

Understand the failure class

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/68fe9a66c87057c9. Report an issue: GitHub.