-
Notifications
You must be signed in to change notification settings - Fork 24
fix: always include grant card in Plain customer cards response #4555
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
When Plain requests the grant card via cardKeys, always include it in
the response even when the user doesn't exist. Previously, if the user
was not found, we returned an empty cards array. Now we return an empty
grant card ({key: "grant", components: []}) to match Plain's expectation
that all requested card keys are always present in the response.
Closes #4553
Co-authored-by: Marco Acierno <marcoacierno@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This comment has been minimized.
This comment has been minimized.
backend/integrations/views.py
Outdated
| if user: | ||
| cards.append(create_grant_card(request, user, conference)) | ||
| else: | ||
| cards.append({"key": "grant", "components": []}) |
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.
@claude this feels like we are leaking the card creation outside. Maybe a better one would be to have create_grant_card check if the user is present, and if not, return the empty card?
This would allow each card in the future to check its own requirements? Review this approach and see if it makes sense
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.
Claude finished @marcoacierno's task in 48s —— View job
- Read current code (
views.py,plain_cards.py) to understand the structure - Evaluate the proposed approach
- Implement the refactor
- Push changes
Good call — the approach makes sense. Moved the user existence check into create_grant_card so each card function encapsulates its own requirements. The view now just does cards.append(create_grant_card(request, user, conference)) without needing to know what each card needs.
Changes:
plain_cards.py:create_grant_cardnow checks ifuserisNonebefore querying for the grant, returning the empty card structure if there's no user.views.py: Simplified to a singlecards.append(...)call — no more branching on user existence in the view.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4555 +/- ##
==========================================
- Coverage 94.16% 94.16% -0.01%
==========================================
Files 353 353
Lines 10348 10346 -2
Branches 762 761 -1
==========================================
- Hits 9744 9742 -2
Misses 502 502
Partials 102 102 🚀 New features to boost your workflow:
|
Each card function now handles its own requirements internally, keeping the view layer clean and making it easier to add new cards. Co-authored-by: Marco Acierno <marcoacierno@users.noreply.github.com>
Closes #4553
Summary
When Plain requests the grant card via
cardKeys, always include it in the response even when the user doesn't exist. Previously, if the user was not found, we returned an empty cards array. Now we return an empty grant card to match Plain's expectation that all requested card keys are always present.Generated with Claude Code