[PR #399] [MERGED] Fix OAuth token fetch failures from ad-hoc response persistence #321

Closed
opened 2026-03-22 21:17:16 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mountain-loop/yaak/pull/399
Author: @gschier
Created: 2/19/2026
Status: Merged
Merged: 2/19/2026
Merged by: @gschier

Base: mainHead: codex/oauth2-ephemeral-response-fix


📝 Commits (1)

  • b8e20a7 Fix OAuth plugin transport errors and ad-hoc response persistence

📊 Changes

3 files changed (+93 additions, -76 deletions)

View changed files

📝 crates/yaak/src/send.rs (+85 -76)
📝 plugins/auth-oauth2/src/fetchAccessToken.ts (+4 -0)
📝 plugins/auth-oauth2/src/getOrRefreshAccessToken.ts (+4 -0)

📄 Description

Summary

  • fix OAuth token fetch/refresh error reporting to surface transport errors from ctx.httpRequest.send() via resp.error
  • fix shared send pipeline for ad-hoc plugin requests (empty request_id) by treating them as ephemeral and skipping DB persistence
  • keep normal persisted-response behavior unchanged for saved requests

Root cause

OAuth uses ctx.httpRequest.send() with an ad-hoc request object (no backing http_requests row). During shared send refactoring, response metadata persistence became unconditional. Persisting http_responses with an empty/nonexistent request_id violates the foreign key constraint, which surfaced as:

Failed to persist response metadata: SQL error: FOREIGN KEY constraint failed

Changes

  • crates/yaak/src/send.rs
    • gate response/event persistence on request_id presence
    • generate an in-memory response ID for ephemeral responses
    • continue returning full response/body for plugin callers
  • plugins/auth-oauth2/src/fetchAccessToken.ts
    • throw immediately when resp.error is present
  • plugins/auth-oauth2/src/getOrRefreshAccessToken.ts
    • throw immediately when resp.error is present

Validation

  • cargo check -p yaak
  • cargo check -p yaak-app
  • npm run -w plugins/auth-oauth2 build --if-present

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mountain-loop/yaak/pull/399 **Author:** [@gschier](https://github.com/gschier) **Created:** 2/19/2026 **Status:** ✅ Merged **Merged:** 2/19/2026 **Merged by:** [@gschier](https://github.com/gschier) **Base:** `main` ← **Head:** `codex/oauth2-ephemeral-response-fix` --- ### 📝 Commits (1) - [`b8e20a7`](https://github.com/mountain-loop/yaak/commit/b8e20a7727ef512fe45bdd0ecf762448dd66b7c8) Fix OAuth plugin transport errors and ad-hoc response persistence ### 📊 Changes **3 files changed** (+93 additions, -76 deletions) <details> <summary>View changed files</summary> 📝 `crates/yaak/src/send.rs` (+85 -76) 📝 `plugins/auth-oauth2/src/fetchAccessToken.ts` (+4 -0) 📝 `plugins/auth-oauth2/src/getOrRefreshAccessToken.ts` (+4 -0) </details> ### 📄 Description ## Summary - fix OAuth token fetch/refresh error reporting to surface transport errors from `ctx.httpRequest.send()` via `resp.error` - fix shared send pipeline for ad-hoc plugin requests (empty `request_id`) by treating them as ephemeral and skipping DB persistence - keep normal persisted-response behavior unchanged for saved requests ## Root cause OAuth uses `ctx.httpRequest.send()` with an ad-hoc request object (no backing `http_requests` row). During shared send refactoring, response metadata persistence became unconditional. Persisting `http_responses` with an empty/nonexistent `request_id` violates the foreign key constraint, which surfaced as: `Failed to persist response metadata: SQL error: FOREIGN KEY constraint failed` ## Changes - `crates/yaak/src/send.rs` - gate response/event persistence on `request_id` presence - generate an in-memory response ID for ephemeral responses - continue returning full response/body for plugin callers - `plugins/auth-oauth2/src/fetchAccessToken.ts` - throw immediately when `resp.error` is present - `plugins/auth-oauth2/src/getOrRefreshAccessToken.ts` - throw immediately when `resp.error` is present ## Validation - `cargo check -p yaak` - `cargo check -p yaak-app` - `npm run -w plugins/auth-oauth2 build --if-present` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-22 21:17:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/yaak#321