flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[DevOps] deploy.sh's custom deploy/init error messages are dead code under set -e

Open K1NGD4VID opened this issue 2 months ago • 4 comments

Labels: devops, infra, third-wave-audit File/location: scripts/deploy.sh:18,152-162,177-191

Description: scripts/deploy.sh sets set -e at the top, then captures stellar contract deploy/stellar contract invoke output via VAR=$(cmd ...) and immediately checks if [[ $? -ne 0 ]] to print a custom error message. Under bash's documented errexit semantics, a failing command substitution used in a plain variable assignment terminates the script immediately (verified empirically: set -e; foo=$(false); echo reached never prints 'reached', script exits 1) so the if [[ $? -ne 0 ]] blocks at lines 158 and 187 can never execute — deploy/init failures instead abort with bash's raw, unhelpful termination and none of the intended '${RED}Error: Deployment failed${NC}' / '${RED}Error: Contract initialization failed${NC}' diagnostics or captured command output are ever shown.

Acceptance Criteria:

  • [ ] Simulate a failing stellar contract deploy (e.g. point --network at an unreachable RPC or invalid secret) and confirm the script prints the intended custom error block and the captured $DEPLOY_OUTPUT, not just a bare non-zero exit.
  • [ ] Fix by checking the command's exit status without going through a plain assignment statement (e.g. if ! DEPLOY_OUTPUT=$(stellar contract deploy ...); then ... fi, or temporarily set +e around the capture) for both the deploy step and the initialize step.

Notes: This is a real bash errexit gotcha, confirmed by running bash -c 'set -e; foo=$(false); echo reached; '; echo $? which exits 1 without printing 'reached'. Distinct from the already-fixed/closed issues about deploy.sh's env-var defaults (#887) and deploy.sh vs deploy.ts divergence (#515) — this is specifically about the failure-handling control flow inside deploy.sh itself.

K1NGD4VID avatar Sep 27 '26 21:09 K1NGD4VID

Hi,

I have experience with similar implementations and would like to take this on.

Technical outline:

  1. Audit storage layout and state invariants ensuring strict auth guards.
  2. Implement deterministic state transitions with safe checked arithmetic.
  3. Add hermetic unit and regression tests covering authorized, unauthorized, and boundary edge cases.
  4. Profile instruction and CPU/gas limits under Soroban host environment.

Let me know if this aligns with the repository guidelines and assign when convenient.

Ranjeet2063 avatar Oct 04 '26 18:10 Ranjeet2063

@anifast-123 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello maintainer, i would like to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @anifast-123 to this issue.

anifast-123 avatar Oct 18 '26 02:10 anifast-123

Congratulations, @anifast-123! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

🧑‍💻 @anifast-123: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Oct 18 '26 02:10 drips-wave[bot]

This issue has been completed by @anifast-123 as part of the Stellar Wave Program's 10th Wave 🥳

😎 @anifast-123: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Oct 18 '26 02:10 drips-wave[bot]