-
Notifications
You must be signed in to change notification settings - Fork 81
Catch unhandled panics in cadence lint and add proper account access checking #2227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this 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
lintFileto gracefully handle internal Cadence checker errors instead of crashing - Implements
MemberAccountAccessHandlerto validateaccess(account)usage based on deployment configuration across networks - Changes
AccessCheckModefromStricttoNotSpecifiedUnrestrictedto 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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:
Now
flow cadence lintalways completes successfully and correctly validates access(account) usage based on deployment configuration.For contributor use:
masterbranchFiles changedin the Github PR explorer