Skip to content

Fix A2AService Compilation and Standardize Zero Trust Mandate Error Handling - #25

Open
dcplatforms wants to merge 1 commit into
mainfrom
jules-7242417214788832787-5d07cd3a
Open

Fix A2AService Compilation and Standardize Zero Trust Mandate Error Handling#25
dcplatforms wants to merge 1 commit into
mainfrom
jules-7242417214788832787-5d07cd3a

Conversation

@dcplatforms

@dcplatforms dcplatforms commented Jul 29, 2026

Copy link
Copy Markdown
Owner

This PR addresses critical syntax and consistency issues within the core Zero Trust validation framework of the Open Commerce Protocol (OCP).

Key Changes:

  1. Removed duplicate MandateService import in src/services/a2aService.js that caused Jest and ESLint parsing/compilation failures.
  2. Aligned MandateService.verifyMandate whitelisting checks to consistently throw standard 'Merchant' instead of 'Recipient' error messages.
  3. Handled token expiration errors in MandateService.verifyMandate gracefully, transforming jsonwebtoken's default TokenExpiredError into the correct 'Zero Trust Validation Failed: Mandate has expired' string.
  4. Harmonized fallback transaction limit checks in AgentService.performA2ATransfer and updated its unit test suite to properly isolate behavior and verify both local logic and a2aService delegation.

All 45 unit and integration tests are passing perfectly, and linter checks pass with zero errors.


PR created automatically by Jules for task 7242417214788832787 started by @dcplatforms


Note

Low Risk
Small consistency and test-isolation changes in validation messaging and imports; no new auth flows or data paths.

Overview
Fixes a duplicate MandateService import in a2aService.js that broke parsing/compilation, and tightens Zero Trust error messaging across mandate verification and agent fallback transfers.

MandateService.verifyMandate now maps JWT TokenExpiredError to a dedicated Mandate has expired message (instead of a generic verification failure), and whitelist failures use Merchant wording to match other mandate paths. AgentService fallback per-transaction limit errors use the same Amount … exceeds agent per-transaction limit phrasing as A2A policy checks.

Unit tests stop wiring a mock a2aService into the default fixture so local limit/counterparty tests hit the fallback path; the delegation case constructs a separate service instance with the mock injected.

Reviewed by Cursor Bugbot for commit 5396231. Configure here.

…ation Error

- Fix syntax/compilation error in a2aService.js by removing duplicate import of MandateService.
- Standardize whitelisting checks in mandate.js to use 'Merchant' instead of 'Recipient'.
- Handle expired jsonwebtoken tokens gracefully by throwing 'Zero Trust Validation Failed: Mandate has expired'.
- Align AgentService local fallback policy validation checks and error prefix consistency.
- Update agent.spec.js to correctly isolate local vs delegating behavior in unit tests.

Co-authored-by: dcplatforms <10982057+dcplatforms@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5396231. Configure here.


const MandateService = require("./mandate");
const logger = require("../utils/logger");
const MandateService = require("./mandate");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expired mandate message double-wrapped

Medium Severity

The executeTransfer function unconditionally wraps errors from its initial mandate check, including the Zero Trust Validation Failed: Mandate has expired error from verifyMandate. This results in A2A callers receiving a nested error message for expired mandates, rather than the intended canonical expiry string.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5396231. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant