Skip to content

Fix batch get requests mutating caller operations - #229

Open
tomeido wants to merge 1 commit into
ainblockchain:developfrom
tomeido:fix/batch-get-input-mutation
Open

tomeido wants to merge 1 commit into
ainblockchain:developfrom
tomeido:fix/batch-get-input-mutation

Conversation

@tomeido

@tomeido tomeido commented Oct 3, 2026

Copy link
Copy Markdown

When the same batch query is reused on a non-root reference, Reference.get() currently rewrites the caller's operation paths. For example, an operation with ref: 'item' at /apps/example requests /apps/example/item on the first call and /apps/example/apps/example/item on the second. Frozen operations also throw during request construction.

Build the batch request from a new array of copied operations, extending each path with the existing helper. This preserves the caller's inputs, operation order and get options.

Regression coverage

Three offline tests cover repeated reads, unchanged inputs with all four operation types and options, and frozen inputs. The mock provider snapshots each request when it is sent so subsequent mutation cannot make the repeated-read test falsely pass.

Validation

Base: develop at c31ca771ac96cdd633e5fc4825dab8ae2ce0deb5.

  • npm test -- --runInBand --runTestsByPath __tests__/ref.test.ts: all 3 tests fail before the fix and all 3 pass after it.
  • npm run build: passed.
  • git diff --check: passed.

Tested with Node 24.19.0, TypeScript 5.4.5, Jest 29.7.0 and ts-jest 29.1.2. The baseline frozen Yarn install rejected the existing lockfile, so local validation used npm install --ignore-scripts --package-lock=false --no-audit --no-fund against the develop manifest followed by the repository's npm run postinstall. No manifest or lockfile changes are included. The full integration suite requiring a local blockchain and test_data.ts was not run.

AI disclosure

Prepared and tested by Codex in ChatGPT Work on behalf of GitHub user tomeido. Submitted for human and maintainer review.

This branch has not been deployed

No deployments
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