Skip to content

Internal agent bug fixes 2#1373

Merged
Ryang-21 merged 14 commits into
masterfrom
bug-fixes-2
Apr 3, 2026
Merged

Internal agent bug fixes 2#1373
Ryang-21 merged 14 commits into
masterfrom
bug-fixes-2

Conversation

@Ryang-21
Copy link
Copy Markdown
Contributor

@Ryang-21 Ryang-21 commented Apr 3, 2026

What

This fixes a collective of bugs documented here

  • Fixed AssembledTransaction.simulate restore path rebuilds wrong operation
  • Added validation to check for malformed federation addresses
  • Statically set AccountResponse fields in the constructor
  • Fixed requestAirdrop error handler accessing the wrong property path
  • Fixed WASM parser offset corruption on continue
  • structToJsonSchema now correctly returns additionalProperties in the root object
  • typeRef now handles Result<ok, err> type
  • Fixed pollTransaction retry being off-by-one
  • CallBuilder.stream() no longer mutates the shared url
  • FederationServer.serverUrl is now cloned before adding query's to prevent url mutation

Ryang-21 and others added 10 commits April 1, 2026 12:26
- pollTransaction: change loop condition from < to <= so attempts=N
  makes N iterations instead of N-1. Fixes crash on attempts=1.
- requestAirdrop: access error.response.data?.detail instead of
  error.response.detail to match feaxios response structure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The ?? operator has lower precedence than >, so
sim.results?.length ?? 0 > 0 was parsed as
sim.results?.length ?? (0 > 0). Added parentheses for correctness.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- structToJsonSchema: move additionalProperties to schema level
- typeRef: handle scSpecTypeResult by returning okType ref
- nativeToScVal: use Number(val) for u32/i32 to handle BigInt inputs
- unionToNative: add missing $ in template literal interpolations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restructure loop so offset = start + sectionLength always executes
at the bottom, preventing offset corruption when nameLen is 0 or
exceeds section bounds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Validate domain format in resolve() to prevent SSRF via userinfo@host
  injection in federation addresses
- Clone serverURL before query() in all three resolve methods to prevent
  permanent destruction of existing query parameters

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use a cloned URL for all streaming operations so that X-Client-Name,
X-Client-Version, cursor, and app headers don't leak into subsequent
call() invocations on the same builder.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When buildWithOp is used (e.g. Client.deploy), store the original
operation so the restore-and-rebuild path reuses it instead of
incorrectly calling contract.call() which fails with invalid
contractId.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use hostname:port as the map key instead of hostname-only so that
servers on different ports of the same host don't overwrite each
other's time data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Import Err from rust_result and check for scvError ScVal type before
unconditionally wrapping as Ok. Error variants now return Err with
the serialized ScError instead of crashing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 3, 2026 00:12
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Apr 3, 2026
@Ryang-21 Ryang-21 requested a review from quietbits April 3, 2026 00:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aggregates several internal bug fixes across Soroban RPC, Horizon, contract spec tooling, federation resolution, and transaction assembly logic, aiming to prevent subtle state corruption and shared-URL mutation issues while improving correctness of parsing/serialization.

Changes:

  • Fixes multiple off-by-one / precedence / property-path bugs in RPC polling, simulation parsing, and Friendbot error handling.
  • Prevents shared URI mutation in streaming and federation requests by cloning URLs before adding query params.
  • Improves contract tooling correctness (WASM custom section parsing, JSON-schema generation, Result<ok, err> handling, and restore-path rebuild operation reuse).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/unit/server/soroban/request_airdrop.test.ts Updates test fixture to match Friendbot error shape (response.data.detail).
src/rpc/server.ts Fixes poll retry count and Friendbot error detail access path.
src/rpc/parsers.ts Fixes boolean precedence when checking results/stateChanges length.
src/horizon/server.ts Uses host:port key when reading cached server time for timebounds.
src/horizon/horizon_axios_client.ts Stores server time cache entries keyed by host:port (from response URL).
src/horizon/call_builder.ts Prevents CallBuilder.stream() from mutating the shared URL by using a clone.
src/horizon/account_response.ts Replaces dynamic field assignment with explicit constructor assignments.
src/federation/server.ts Adds domain validation for federation addresses and prevents serverURL query mutation via clone.
src/contract/utils.ts Fixes WASM custom section parsing to always advance to end-of-section to avoid offset corruption.
src/contract/spec.ts Improves Result handling, root additionalProperties, bigint->U32/I32 conversion, and error message interpolation.
src/contract/assembled_transaction.ts Stores original operation from buildWithOp and reuses it during restore-path rebuilds.
Comments suppressed due to low confidence (1)

src/rpc/server.ts:733

  • pollTransaction now performs maxAttempts calls (good), but it also sleeps after the final attempt when the transaction is still NOT_FOUND. That makes the total wait time longer than necessary and contradicts the idea of "sleep between attempts".

Suggestion: only sleep when attempt < maxAttempts (or restructure as a do/while) so there is no post-final sleep before returning the last-seen status.

    for (let attempt = 1; attempt <= maxAttempts; attempt++) {
      foundInfo = await this.getTransaction(hash);
      if (foundInfo.status !== Api.GetTransactionStatus.NOT_FOUND) {
        return foundInfo;
      }

      await Utils.sleep((opts?.sleepStrategy ?? BasicSleepStrategy)(attempt));
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/federation/server.ts
Comment thread src/contract/spec.ts
Comment on lines 805 to 811
case "bigint": {
switch (value) {
case xdr.ScSpecType.scSpecTypeU32().value:
return xdr.ScVal.scvU32(val as number);
return xdr.ScVal.scvU32(Number(val));
case xdr.ScSpecType.scSpecTypeI32().value:
return xdr.ScVal.scvI32(val as number);
return xdr.ScVal.scvI32(Number(val));
case xdr.ScSpecType.scSpecTypeU64().value:
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

Number(val) allows bigint inputs for U32/I32, but it can silently lose precision for bigints > 2^53-1. Even though valid U32/I32 ranges are below 2^53, a caller can still pass an out-of-range bigint and get an incorrect/scary conversion rather than a clear error.

Consider validating that bigint values are within the allowed numeric range (and are integral) before converting to Number, and throw a TypeError on overflow.

Copilot uses AI. Check for mistakes.
Comment thread src/contract/assembled_transaction.ts
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 3, 2026

Size Change: +171 kB (+0.38%)

Total Size: 45.6 MB

📦 View Changed
Filename Size Change
dist/stellar-sdk-minimal.js 6.04 MB +28 kB (+0.47%)
dist/stellar-sdk-minimal.min.js 5.13 MB +14.7 kB (+0.29%)
dist/stellar-sdk-no-axios.js 6.04 MB +28 kB (+0.47%)
dist/stellar-sdk-no-axios.min.js 5.13 MB +14.7 kB (+0.29%)
dist/stellar-sdk-no-eventsource.js 6.31 MB +28 kB (+0.45%)
dist/stellar-sdk-no-eventsource.min.js 5.35 MB +14.7 kB (+0.28%)
dist/stellar-sdk.js 6.31 MB +28 kB (+0.45%)
dist/stellar-sdk.min.js 5.35 MB +14.7 kB (+0.28%)

compressed-size-action

@Ryang-21 Ryang-21 merged commit 9ec7ffd into master Apr 3, 2026
10 checks passed
@Ryang-21 Ryang-21 deleted the bug-fixes-2 branch April 3, 2026 23:46
@github-project-automation github-project-automation Bot moved this from Backlog (Not Ready) to Done in DevX Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants