Skip to content

fix(cli): prevent panic on single-change extend resultMetaXdr (#2796) - #2815

Closed
jdjioe5-cpu wants to merge 1 commit into
stellar:mainfrom
jdjioe5-cpu:fix/issue-2796-extend-single-change-panic
Closed

jdjioe5-cpu wants to merge 1 commit into
stellar:mainfrom
jdjioe5-cpu:fix/issue-2796-extend-single-change-panic

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

Summary

Closes #2796.

This PR addresses the panic in stellar contract extend where a transaction result metadata with a single operation carrying exactly one LedgerEntryChange passed previous non-empty guards but panicked at cmd/soroban-cli/src/commands/contract/extend.rs:306 with index out of bounds: the len is 1 but the index is 1 during the tuple matching match (&changes[0], &changes[1]).

Changes

  1. Replaces raw 2-element index access on changes with iterator-based parse_changes pattern matching
    estore.rs.
  2. Searches for Updated or Created ledger entries while safely tracking State entry references without out-of-bounds indexing.
  3. Gracefully returns Error::LedgerEntryNotFound when expected changes are absent or invalid.
  4. Adds regression unit tests covering:
    • Single-change updated entry avoiding index panic ( est_parse_changes_single_change_updated_avoids_panic)
    • Empty changes returning LedgerEntryNotFound ( est_parse_changes_empty_returns_not_found)
    • Single-change created entry ( est_parse_changes_single_change_created)
    • Two-change sequence with state followed by updated ( est_parse_changes_state_then_updated)

@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Oct 22, 2026
@github-project-automation github-project-automation Bot moved this from Backlog (Not Ready) to Done in DevX Oct 25, 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.

contract extend panics on single-change resultMetaXdr (index out of bounds at extend.rs:306)

2 participants