Repository navigation
feat(web_core): add MessageErrorMapper, JSON Pointer error paths, and conformance parity - #3579
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces structured outbound renderer error mapping and reporting. It adds helper utilities mapErrorToRendererMessage and extractEnvelopeErrorContext to map internal A2uiError instances into spec-compliant ErrorMessage envelopes, and updates MessageProcessor to emit these errors via errorHandler, onError, and a new processMessagesWithErrors method. Additionally, it enhances validation errors with precise RFC 6901 JSON Pointer paths and updates conformance tests to validate these behaviors. The review feedback suggests replacing the in operator with Object.hasOwn in several files to avoid potential prototype lookup issues.
9f1b254 to
720309d
Compare
c53e138 to
c23724a
Compare
c23724a to
dea7347
Compare
c237880 to
862a59b
Compare
a0164e5 to
1cac8c9
Compare
ditman
left a comment
There was a problem hiding this comment.
Thanks for taking a stab at this. I unleashed Carbon on this and it found a few things; most of them actually look legit, I'm surprised. LMK if things are not actionable enough, I can ask it to be more specific or prepare better suggestions!
7fe475c to
7dccce8
Compare
7dccce8 to
05bcd94
Compare
ditman
left a comment
There was a problem hiding this comment.
Thanks for addressing the Round 1 feedback. Can you please fix the small leftover from earlier?
- Breaking
OutboundMessageListenerunion widening (src/rpc/rpc-handler.ts): Now thatMessageProcessor.handleProcessingErrorroutes errors exclusively througherrorHandler/onErrorand no longer callsoutboundListener,OutboundMessageListenernever receivesErrorMessage. Revertingrpc-handler.tsavoids an unannounced breaking compile-time change for@a2ui/web_core/v1_0consumers narrowingOutboundMessageListener'smessageparameter.
The rest of my comments are nits, take as needed!
…closures Revert OutboundMessageListener to omit ErrorMessage so @a2ui/web_core/v1_0 callers are not widened, drop redundant ProcessingErrorMessage and ErrorMessage aliases from message-error-mapper, track per-item ErrorEnvelopeContext during prepareOperations across multi-message arrays, restore async closure syntax in GenericBinder.bindAction, and remove the duplicate strictMode spread in conformance_test.mjs.
Resolve conflicts in @a2ui/web_core with PR a2ui-project#3579 (DataContext.resolveAction delegation, MessageErrorMapper, and node-resolution conformance steps) while preserving ActionDispatchOptions and extension metadata propagation.
Summary
Implement renderer-to-agent outbound error mapping, RFC 6901 JSON Pointer error paths, and headless core conformance runner parity in
@a2ui/web_core.Reviewer Focus
typescript/core/web_core/src/processing/message-error-mapper.ts:extractEnvelopeErrorContextandmapErrorToRendererMessagemap internal core errors to versionedErrorMessageenvelopes across v0.9, v0.9.1, and v1.0 protocols.functionCallIdfor envelope-level faults oncallRendererFunction./components/0,/components/0/children/1).MessageProcessor.tsandSurfaceGroupModel.ts:ErrorMessagepayloads are dispatched tosurface.onError,model.onError, andoutboundListenercallbacks before errors are re-thrown inprocessMessages.processMessagesWithErrorsprovides a non-throwing alternative for batch processing.GenericBinder.ts:event.contextwithout treating literal map keyspathorcallas binding directives.Unit tests and CHANGELOG updates can be skimmed.
Changes
src/processing/message-error-mapper.tsimplementingMessageErrorMapper,extractEnvelopeErrorContext, andnormalizeJsonPointer.src/processing/index.ts,src/v0_9/index.ts, andsrc/v1_0/index.ts.onErrorevent hooks toSurfaceGroupModelandSurfaceComponentsModel.processMessagesWithErrorstoMessageProcessor.MessageProcessor.processMessagesto emit mappedErrorMessageinstances to error listeners before rethrowing.payload-validator.tsandvalidation-helpers.tsto emit structuredA2uiErrorDetaillists with canonical RFC 6901 JSON Pointer paths.GenericBinderinsrc/resolution/generic-binder.tsto evaluate action context entries individually.NodeResolverdiagnostics with conformance expectations.tests/conformance/conformance_test.mjsandtests/conformance/node-resolution.tsto validateexpectError.details,expectError.rendererError,strictMode,ValidationResultseverity properties (isValid,validationErrors,validationResults), andsurfaceId-scoped RPC dispatch.CHANGELOG.mdfor@a2ui/web_core.Impact & Risks
ErrorMessagenotifications are now emitted when processing invalid messages, giving agents structured feedback on protocol violations.MessageProcessor.processMessagescontinue to receive thrown errors; error listener callbacks are invoked prior to the throw.Testing
Run the build, conformance tests, and linter:
🤖 Agent-generated