Skip to content

fix(agent-service): send the delegate user's token on compile requests - #9079

Merged
mengw15 merged 2 commits into
apache:mainfrom
sshiv012:sshiv012/agentsvc-visionkb-bugs
Nov 2, 2026
Merged

mengw15 merged 2 commits into
apache:mainfrom
sshiv012:sshiv012/agentsvc-visionkb-bugs

Conversation

@sshiv012

@sshiv012 sshiv012 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

compileWorkflowAsync called the JWT-protected /api/compile (@RolesAllowed(REGULAR, ADMIN) behind JwtAuthFilter, since #5199 / #5404) with only Content-Type, so every agent compile returned 401. The agent silently proceeded without operator output schemas or compile errors.

Before:  prepareStep -> POST /api/compile (no Authorization)      -> 401 -> null
After:   prepareStep -> POST /api/compile (Bearer <delegate token>) -> 200 -> schemas + operatorErrors
File Change
api/compile-api.ts optional token param; sends createAuthHeaders(token) when present (no-token behavior unchanged)
agent/texera-agent.ts prepareStep passes this.delegateConfig?.userToken

Audited the other agent-service HTTP calls: workflow persist/retrieve and execution already send the Bearer token; /api/resources/operator-metadata is public. Compile was the only gap.

Any related issues, documentation, discussions?

Closes #9078

How was this PR tested?

Regression tests written first (failed before the fix, pass after):

  • compile-api.spec.ts: sends Authorization: Bearer <token> when given; omits it for an empty token; against a mock that mirrors JwtAuthFilter (401 without Bearer, 200 with), returns null without a token and the schemas with one.
  • texera-agent.spec.ts: in delegate mode, every compile request carries Bearer <delegate token>.
cd agent-service
bun test             # 314 pass, 0 fail (19 files)
bun run typecheck    # tsc --noEmit, exit 0
bun run format:check # All matched files use Prettier code style!

Verified end-to-end against a running cluster.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)

🤖 Generated with Claude Code

@sshiv012

Copy link
Copy Markdown
Contributor Author

/request-review @bobbai00

The workflow-compiling-service /api/compile endpoint is JWT-protected
(@RolesAllowed REGULAR/ADMIN behind JwtAuthFilter), but
compileWorkflowAsync sent only Content-Type, so every compile returned
401 and the agent silently ran without operator schemas or compile
errors. Thread delegateConfig.userToken into compileWorkflowAsync and
send createAuthHeaders(token) when present.

Closes apache#9078

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sshiv012
sshiv012 force-pushed the sshiv012/agentsvc-visionkb-bugs branch from a1c8aa9 to 3fbc9ec Compare October 21, 2026 23:03
@bobbai00
bobbai00 self-requested a review October 21, 2026 23:14
@mengw15 mengw15 added release/v1.2 back porting to release/v1.2 release/v1.3 back porting to release/v1.3 labels Oct 21, 2026
@github-actions github-actions Bot removed the fix label Oct 22, 2026
@github-actions
github-actions Bot requested review from mengw15 and xuang7 October 22, 2026 00:14
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
✅ release/v1.3 Change detected on this branch — label added; this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.
✅ release/v1.2 Change detected on this branch — label added; this fix is queued to backport here. @xuang7 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.

Auto-label run.

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @roshiiiz, @mengw15, @bobbai00
    You can notify them by mentioning @roshiiiz, @mengw15, @bobbai00 in a comment.

@codecov-commenter

codecov-commenter commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.27%. Comparing base (05c19a4) to head (66d9c43).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9079      +/-   ##
============================================
+ Coverage     92.17%   92.27%   +0.10%     
  Complexity     5043     5043              
============================================
  Files          1287     1287              
  Lines         55799    56423     +624     
  Branches       7144     7144              
============================================
+ Hits          51434    52066     +632     
+ Misses         2598     2593       -5     
+ Partials       1767     1764       -3     
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from c699889
agent-service 99.71% <100.00%> (+0.16%) ⬆️
amber 86.90% <ø> (ø) Carriedforward from c699889
computing-unit-managing-service 64.02% <ø> (ø) Carriedforward from c699889
config-service 87.61% <ø> (ø) Carriedforward from c699889
file-service 82.29% <ø> (ø) Carriedforward from c699889
frontend 96.48% <ø> (+<0.01%) ⬆️ Carriedforward from c699889
notebook-migration-service 83.77% <ø> (ø) Carriedforward from c699889
pyamber 98.54% <ø> (+0.06%) ⬆️ Carriedforward from c699889
workflow-compiling-service 77.95% <ø> (ø) Carriedforward from c699889

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sshiv012

sshiv012 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

The agent calls /api/compile without the user's login token, so every compile request gets a 401 and the agent quietly works without output schemas or compile errors. This PR sends the delegate user's token on that call, and v1.2 has the same unauthenticated call, so the agent there is just as blind to compile errors. @xuang7 and @mengw15, please review!

@bobbai00 bobbai00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mengw15 mengw15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mengw15 mengw15 removed the release/v1.2 back porting to release/v1.2 label Nov 2, 2026
@mengw15
mengw15 enabled auto-merge November 2, 2026 23:08
@mengw15
mengw15 added this pull request to the merge queue Nov 2, 2026
Merged via the queue into apache:main with commit 07fffb3 Nov 2, 2026
59 of 62 checks passed
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Backport PR opened: #9268 (#9268) to release/v1.3 — the cherry-pick was clean, so it is ready for review, waiting on @mengw15. It needs to be reopened once to start its checks; the PR says how.

aglinxinyuan added a commit to aglinxinyuan/texera that referenced this pull request Nov 8, 2026
The agent builds a plan for its per-step compile (WorkflowState.toLogicalPlan)
and for its runs (executeOperatorAndFormat), and both send a link into the
control-variable port, which is none of an operator's input ports, to data
port 0. Main's apache#9079 made the agent's compile succeed, so the agent now
gets compile errors and schemas for links the user never drew. These cases
expect port -1, as the frontend sends it, and fail until both builders map it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-service release/v1.3 back porting to release/v1.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent service compile requests are rejected with 401 because no auth token is sent

4 participants