Read bodies of responses the engine never recorded

A send with no request behind it — a plugin's ad-hoc ctx.httpRequest.send,
GraphQL introspection — gets a generated id and a body file, but no row.
Resolving purely through the database refused those, which would have
broken auth-oauth2 the moment it moved off readFileSync, since every
request it sends is ad-hoc.

The store now falls back to the response directory when there is no row,
accepting only ids shaped the way the engine generates them. Such a
response has no stored headers, so contentType is null and text()
decodes as UTF-8 — which is what the filesystem readers did anyway.
This commit is contained in:
Gregory Schier
2026-08-16 09:35:03 -07:00
parent 96c8a95094
commit 8b031db685
5 changed files with 89 additions and 26 deletions
@@ -53,9 +53,13 @@ pub(crate) async fn handle_plugin_event<R: Runtime>(
.and_then(|window| workspace_from_window(&window).map(|workspace| workspace.id))
});
// Same directory the engine writes bodies into, so responses it never
// recorded are still readable by id.
let response_dir = app_handle.path().app_data_dir()?.join("responses");
match handle_shared_plugin_event(
app_handle.db_manager().inner(),
&FileResponseBodyStore::new(app_handle.db_manager().inner()),
&FileResponseBodyStore::new(app_handle.db_manager().inner(), &response_dir),
&event.payload,
SharedPluginEventContext {
plugin_name: &plugin_name,