Skip to content

fix(getag): render fees breakdown when metadata has no inputs - #296

Open
alexmarqs wants to merge 1 commit into
mainfrom
claude/lucid-keller-7w7udr
Open

fix(getag): render fees breakdown when metadata has no inputs#296
alexmarqs wants to merge 1 commit into
mainfrom
claude/lucid-keller-7w7udr

Conversation

@alexmarqs

Copy link
Copy Markdown
Member

Summary

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 (caller type api_client) therefore carry the compute result without it.

processExternalFeesDetails runs for every item that has external_fees_metadata (variables/process-order-table-data.ts:428) and dereferenced inputs unguarded:

  • variables/getag/network-fees-details.ts:16externalFeesMetadata.inputs.type
  • variables/getag/other-fees-details.ts:18 — same
  • variables/getag/utils.ts:201,202,269,270inputs.consumptionHT/NT

There 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

  • Optional-chain the four read sites.
  • Type ExternalFeesMetadata['inputs'] as optional, matching ExternalFeeMetadata in 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.
  • Two regression tests in variables/getag/utils.test.ts covering metadata without inputs for 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 inputs is present. getConsumptionBasedAmounts already treats an unknown consumption as 0 and returns undefined, 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:

Follow-up (not in this PR)

The durable fix is for pricing-api to echo the request inside the signed compute response. inputs today is unsigned (cart-checkout strips it before verifying the signature), incomplete (billing_period, meter_type, concession_type, reference_date are not in it) and only ever written by one client. Until then, a gas tariff computed via the API renders with the power groupings, since type falls back to power.

Test plan

  • pnpm typecheck — clean
  • pnpm test — 31 files, 639 tests pass (637 before, +2 new)
  • New tests verified to fail without the guard, with the production error

🤖 Generated with Claude Code

https://claude.ai/code/session_01Us3D1FV7drsasWCs791fAX


Generated by Claude Code

`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-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 58f9f5d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@epilot/pricing Patch

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

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.

2 participants