fix(getag): render fees breakdown when metadata has no inputs - #296
Open
alexmarqs wants to merge 1 commit into
Open
fix(getag): render fees breakdown when metadata has no inputs#296alexmarqs wants to merge 1 commit into
alexmarqs wants to merge 1 commit into
Conversation
`external_fees_metadata.inputs` is annotated client-side by the Journey renderer right after the GetAG compute call — the pricing API never returns it. Price items coming from carts submitted through the public API therefore carry the compute result without it. `processExternalFeesDetails` dereferenced `inputs.type` and `inputs.consumptionHT/NT` unguarded and threw `Cannot read properties of undefined`, which takes down the entire order table variable for those items, not just the breakdown. Optional-chain the reads and type `ExternalFeesMetadata['inputs']` as optional to match the API schema. `getConsumptionBasedAmounts` already treats an unknown consumption as `0` and renders `-`, so the breakdown comes out complete apart from the consumption-based yearly figures. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Us3D1FV7drsasWCs791fAX
🦋 Changeset detectedLatest commit: 58f9f5d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
external_fees_metadata.inputsis annotated client-side by the Journey renderer right after the GetAG compute call — the pricing API never returns it. Price items coming from carts submitted through the public API (caller typeapi_client) therefore carry the compute result without it.processExternalFeesDetailsruns for every item that hasexternal_fees_metadata(variables/process-order-table-data.ts:428) and dereferencedinputsunguarded:variables/getag/network-fees-details.ts:16—externalFeesMetadata.inputs.typevariables/getag/other-fees-details.ts:18— samevariables/getag/utils.ts:201,202,269,270—inputs.consumptionHT/NTThere is no try/catch on that path, so it throws
Cannot read properties of undefined (reading 'type')and takes down the whole order table variable for the item, not just the fees breakdown.Changes
ExternalFeesMetadata['inputs']as optional, matchingExternalFeeMetadatain the pricing API schema, where it has always been optional. This is the type change consumers will notice — it is deliberate: it forces the guard at every read.variables/getag/utils.test.tscovering metadata withoutinputsfor the work-price and procurement markups. Both reproduce the exact production error before the fix (Cannot read properties of undefined (reading 'consumptionHT' / 'consumptionNT')).No behaviour change when
inputsis present.getConsumptionBasedAmountsalready treats an unknown consumption as0and returnsundefined, which renders as-, so the breakdown comes out complete apart from the consumption-based yearly figures.Changeset added (
patch).Related
Same defect in the two UI consumers of this field, fixed in parallel:
journey-monorepo— https://gitlab.com/e-pilot/product/journey/journey-monorepo/-/merge_requests/6204epilot360-entity— https://gitlab.com/e-pilot/product/360-portal/epilot360-entity/-/merge_requests/4406Follow-up (not in this PR)
The durable fix is for pricing-api to echo the request inside the signed compute response.
inputstoday is unsigned (cart-checkout strips it before verifying the signature), incomplete (billing_period,meter_type,concession_type,reference_dateare not in it) and only ever written by one client. Until then, a gas tariff computed via the API renders with the power groupings, sincetypefalls back topower.Test plan
pnpm typecheck— cleanpnpm test— 31 files, 639 tests pass (637 before, +2 new)🤖 Generated with Claude Code
https://claude.ai/code/session_01Us3D1FV7drsasWCs791fAX
Generated by Claude Code