Skip to content

Conversation

@jribbink
Copy link
Contributor

@jribbink jribbink commented Dec 18, 2025

Closes #2228

Description

Previously, when the Cadence semantic checker encountered certain code patterns (like optional chaining on reference types), it would panic instead of returning an error, causing the entire lint command to crash.

This fix:

  1. Adds panic recovery to gracefully handle internal Cadence checker errors
  2. Implements proper MemberAccountAccessHandler that checks if contracts are deployed to the same account across networks (similar to PR #531 in cadence-tools for the language server)

Now flow cadence lint always completes successfully and correctly validates access(account) usage based on deployment configuration.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Previously, when the Cadence semantic checker encountered certain code
patterns (like optional chaining on reference types), it would panic
instead of returning an error, causing the entire lint command to crash.

This fix:
1. Adds panic recovery to gracefully handle internal Cadence checker errors
2. Implements proper MemberAccountAccessHandler that checks if contracts
   are deployed to the same account across networks (similar to PR #531
   in cadence-tools for the language server)
3. Uses AccessCheckModeNotSpecifiedUnrestricted to be permissive during linting

Now `flow cadence lint` always completes successfully and correctly
validates access(account) usage based on deployment configuration.
@github-actions
Copy link

github-actions bot commented Dec 18, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter
Copy link

codecov-commenter commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 5.06329% with 75 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/cadence/linter.go 5.71% 64 Missing and 2 partials ⚠️
internal/cadence/lint.go 0.00% 7 Missing ⚠️
internal/tools/wallet.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jribbink jribbink added Bugfix Improvement Technical work without new features, refactoring, improving tests and removed Bugfix labels Dec 18, 2025
@jribbink jribbink changed the title Fix panic in cadence lint and add proper account access checking Catch unhandled panics in cadence lint and add proper account access checking Dec 18, 2025
@jribbink jribbink marked this pull request as ready for review December 18, 2025 23:08
@chasefleming chasefleming requested a review from Copilot December 19, 2025 03:46
Copy link

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 improves the robustness of the flow cadence lint command by adding panic recovery and implementing proper account access checking for Cadence contracts.

Key changes:

  • Adds panic recovery in lintFile to gracefully handle internal Cadence checker errors instead of crashing
  • Implements MemberAccountAccessHandler to validate access(account) usage based on deployment configuration across networks
  • Changes AccessCheckMode from Strict to NotSpecifiedUnrestricted to work with the new account access handler

Reviewed changes

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

File Description
internal/cadence/linter.go Adds panic recovery, implements account access checking logic with helper functions, and configures the semantic checker with the new handler
internal/cadence/lint.go Converts internal errors from panic recovery into diagnostics to allow continued processing of remaining files

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

jribbink and others added 2 commits December 18, 2025 22:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jribbink jribbink merged commit c8ae793 into master Dec 19, 2025
9 checks passed
@jribbink jribbink deleted the jribbink/lint-improvements branch December 19, 2025 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement Technical work without new features, refactoring, improving tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flow cadence lint does not implement account access checks

4 participants