Uh oh!
There was an error while loading. Please reload this page.
refactor(api): enforce type annotations on whitelisted methods - #306
Closed
github-actions[bot] wants to merge 1 commit into
Closed
refactor(api): enforce type annotations on whitelisted methods#306github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
* refactor(api): enforce type annotations on whitelisted methods Turn on require_type_annotated_api_methods so Frappe rejects any whitelisted method whose arguments are not annotated. No annotations had to be added: typing_validations.py skips the first parameter when it is self/cls, and every whitelisted controller method in the app takes only self. This is runtime cover for what CI already blocks statically. The Linters workflow runs frappe/semgrep-rules, whose missing-argument-type-hint rule (rules/security/whitelisted.yml) fails the build on an unannotated whitelisted argument. The hook catches what a syntactic rule cannot see, and unlike semgrep it cannot be silenced with a nosemgrep comment. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * refactor: drop a stray whitelist and use frappe.parse_json BuzzEvent.after_insert was whitelisted, which made a lifecycle hook remotely re-runnable through run_doc_method. Re-running it duplicates the default sponsorship tiers and ticket types and then calls save(ignore_permissions=True). Nothing calls it remotely. Replace the last two json.loads calls with frappe.parse_json. It already returns a frappe._dict for dict payloads, so payments.py collapses to a single call and its function-local import goes with it. In event_booking.py the except clause widens to (ValueError, TypeError): orjson.JSONDecodeError subclasses json.JSONDecodeError so the old clause still caught it, but naming json there was the last reason to keep the module imported. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> (cherry picked from commit a4f52b2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated backport of #303 to
main.