Skip to content
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

feat(native-app): add barcode session error #17623

Merged
merged 7 commits into from
Jan 25, 2025

Conversation

thoreyjona
Copy link
Contributor

@thoreyjona thoreyjona commented Jan 22, 2025

What

If I get BAD_SESSION error when fetching a barcode I show an error message that states that it is too short since license was accessed on another device. Need to merge #17541 before this.

Screenshots / Gifs

(The spacing below the picture has already been fixed)
Simulator Screenshot - iPhone 16 Pro - 2025-01-22 at 11 19 21

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new error handling for wallet pass sessions, allowing for more specific user feedback.
  • Bug Fixes

    • Improved error detection and messaging for license access across devices.
    • Enhanced error handling in the License Card component for better clarity on session-related issues.
  • Localization

    • Added new error messages in English and Icelandic for wallet pass scenarios.

This update enhances the user experience by providing clearer guidance during potential session-related issues when accessing licenses from multiple devices.

@thoreyjona thoreyjona requested review from a team as code owners January 22, 2025 20:09
Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

Walkthrough

This pull request introduces enhanced error handling for wallet pass functionality across multiple files. The changes focus on improving session-related error management by adding new localized error messages for bad session scenarios and modifying the error handling logic in the LicenseCard component. The modifications enable more detailed error reporting, specifically addressing situations where a license is accessed from multiple devices within a short time frame.

Changes

File Change Summary
apps/native/app/src/messages/en.ts Added new error message 'walletPass.barcodeErrorBadSession' for English localization
apps/native/app/src/messages/is.ts Added new error message 'walletPass.barcodeErrorBadSession' for Icelandic localization
apps/native/app/src/screens/wallet-pass/wallet-pass.tsx Modified error handling logic, changing error={!!res.error} to error={res.error}
apps/native/app/src/ui/lib/card/license-card.tsx Updated error property type from boolean to ApolloError, added findProblemInApolloError for nuanced error handling
libs/shared/problem/src/utils/findProblemInApolloError.ts Added ProblemExtensions interface, enhanced error problem extraction logic
libs/shared/problem/src/utils/findProblemInApolloError.spec.ts Added test case for nested error problem detection

Possibly related PRs

Suggested labels

automerge, deploy-feature

Suggested reviewers

  • thorkellmani
  • eirikurn
  • snaerseljan

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 99af476 and 5fdb0a7.

📒 Files selected for processing (2)
  • apps/native/app/src/screens/wallet-pass/wallet-pass.tsx (1 hunks)
  • apps/native/app/src/ui/lib/card/license-card.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/native/app/src/screens/wallet-pass/wallet-pass.tsx
🧰 Additional context used
📓 Path-based instructions (1)
apps/native/app/src/ui/lib/card/license-card.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (4)
apps/native/app/src/ui/lib/card/license-card.tsx (4)

11-11: LGTM! Clean import organization.

The new imports are well-organized and properly grouped between external and internal dependencies.

Also applies to: 26-29


174-176: Remove type cast and improve type safety.

The type cast to any suggests potential type safety issues. Consider improving type safety by properly typing the error parameter.


309-311: LGTM! Clean error message selection logic.

The conditional logic for selecting error messages is well-structured and properly internationalized.


131-131: Verify parent components for breaking changes.

The type change from boolean to ApolloError for the error prop is a breaking change. This enables more granular error handling but requires updates in all parent components.

✅ Verification successful

The error prop type change is safe to proceed with

The codebase scan shows only one production component passing the error prop (wallet-pass.tsx), and it's already using an Apollo error object. This type change actually makes the interface more accurate.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for components passing the error prop to LicenseCard
ast-grep --pattern 'error={$_}' | rg -B 5 -A 5 'LicenseCard'

Length of output: 60


Script:

#!/bin/bash
# Find files importing and using LicenseCard
echo "=== Files importing LicenseCard ==="
rg -l "import.*LicenseCard" --type typescript --type tsx

echo -e "\n=== LicenseCard usage contexts ==="
rg -B 5 -A 5 "<LicenseCard" --type typescript --type tsx

Length of output: 353


Script:

#!/bin/bash
echo "=== Files importing LicenseCard ==="
rg -l "import.*LicenseCard" -g "*.{ts,tsx}"

echo -e "\n=== LicenseCard usage contexts ==="
rg -B 5 -A 5 "<LicenseCard" -g "*.{ts,tsx}"

Length of output: 7783


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.56%. Comparing base (fa5f883) to head (5fdb0a7).
Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17623   +/-   ##
=======================================
  Coverage   35.56%   35.56%           
=======================================
  Files        7033     7033           
  Lines      150624   150626    +2     
  Branches    43023    43021    -2     
=======================================
+ Hits        53562    53564    +2     
  Misses      97062    97062           
Flag Coverage Δ
air-discount-scheme-backend 48.13% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
api-domains-air-discount-scheme 37.84% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.49% <ø> (ø)
api-domains-communications 39.45% <0.00%> (-0.02%) ⬇️
api-domains-criminal-record 47.73% <ø> (ø)
api-domains-driving-license 44.74% <ø> (ø)
api-domains-education 31.03% <ø> (ø)
api-domains-health-insurance 35.09% <ø> (ø)
api-domains-mortgage-certificate 34.91% <ø> (ø)
api-domains-payment-schedule 41.98% <ø> (ø)
application-api-files 61.73% <ø> (ø)
application-core 75.68% <ø> (ø)
application-system-api 38.64% <0.00%> (+<0.01%) ⬆️
application-template-api-modules 27.56% <0.00%> (-0.01%) ⬇️
application-templates-accident-notification 27.60% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.79% <ø> (ø)
application-templates-driving-license 18.15% <ø> (ø)
application-templates-estate 13.57% <0.00%> (-0.01%) ⬇️
application-templates-example-payment 24.66% <ø> (ø)
application-templates-financial-aid 14.99% <ø> (ø)
application-templates-general-petition 23.11% <ø> (ø)
application-templates-inheritance-report 6.59% <ø> (ø)
application-templates-marriage-conditions 14.80% <ø> (ø)
application-templates-mortgage-certificate 43.73% <ø> (ø)
application-templates-new-primary-school 20.60% <ø> (ø)
application-templates-parental-leave 29.92% <ø> (ø)
application-types 6.47% <ø> (ø)
application-ui-components 1.17% <ø> (ø)
application-ui-shell 21.98% <0.00%> (-0.02%) ⬇️
clients-charge-fjs-v2 28.88% <ø> (ø)
clients-driving-license 40.60% <ø> (ø)
clients-driving-license-book 43.69% <ø> (ø)
clients-financial-statements-inao 49.41% <ø> (ø)
clients-license-client 1.26% <ø> (ø)
clients-middlewares 72.49% <ø> (-0.33%) ⬇️
clients-regulations 42.66% <ø> (ø)
clients-rsk-company-registry 31.18% <ø> (ø)
clients-syslumenn 49.14% <ø> (ø)
cms 0.38% <ø> (ø)
cms-translations 38.79% <ø> (ø)
judicial-system-api 20.07% <ø> (ø)
judicial-system-backend 55.79% <ø> (ø)
license-api 42.83% <0.00%> (-0.04%) ⬇️
nest-problem 45.52% <0.00%> (-0.18%) ⬇️
nest-swagger 50.63% <0.00%> (-0.66%) ⬇️
services-auth-admin-api 52.49% <0.00%> (-0.02%) ⬇️
services-auth-delegation-api 58.49% <0.00%> (-0.03%) ⬇️
services-auth-ids-api 52.46% <0.00%> (-0.04%) ⬇️
services-auth-public-api 49.33% <0.00%> (-0.02%) ⬇️
services-sessions 65.15% <0.00%> (-0.12%) ⬇️
services-university-gateway 49.48% <0.00%> (+0.11%) ⬆️
services-user-notification 46.49% <0.00%> (+0.04%) ⬆️
services-user-profile 56.77% <0.00%> (-0.14%) ⬇️
shared-problem 89.65% <100.00%> (+1.65%) ⬆️
web 2.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ared/problem/src/utils/findProblemInApolloError.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa5f883...5fdb0a7. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 22, 2025

Datadog Report

All test runs 059c104 🔗

8 Total Test Services: 0 Failed, 7 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 1 increased (+0.08%), 11 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 6.44s 1 no change Link
application-system-api 0 0 0 46 0 2m 21.17s 1 no change Link
application-template-api-modules 0 0 0 96 0 0s N/A Link
application-templates-financial-aid 0 0 0 11 0 30.12s 1 increased (+0.08%) Link
judicial-system-backend 0 0 0 20030 0 11m 35.49s 1 no change Link
services-auth-delegation-api 0 0 0 270 0 3m 20.45s 1 decreased (-0.01%) Link
services-auth-personal-representative 0 0 0 0 0 475.67ms 1 no change Link
web 0 0 0 84 0 53.65s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • services-auth-delegation-api - jest 50.44% (-0.01%) - Details

@thoreyjona thoreyjona requested review from a team as code owners January 22, 2025 20:43
@eirikurn eirikurn force-pushed the feat/add-barcode-session-error branch from c9e79a7 to 89bd79e Compare January 24, 2025 09:24
Copy link
Member

@eirikurn eirikurn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@eirikurn eirikurn removed request for a team January 24, 2025 09:25
@eirikurn eirikurn enabled auto-merge January 24, 2025 09:25
@datadog-island-is
Copy link

datadog-island-is bot commented Jan 24, 2025

Datadog Report

All test runs 2d8a037 🔗

10 Total Test Services: 0 Failed, 10 Passed
🔻 Test Sessions change in coverage: 11 decreased, 3 increased, 181 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 63 0 15.81s N/A Link
air-discount-scheme-web 0 0 0 2 0 6.47s N/A Link
api 0 0 0 4 0 2.46s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 16.68s 1 no change Link
api-domains-assets 0 0 0 3 0 9.71s N/A Link
api-domains-auth-admin 0 0 0 18 0 10.33s 1 no change Link
api-domains-communications 0 0 0 5 0 31.2s 1 decreased (-0.02%) Link
api-domains-criminal-record 0 0 0 5 0 8.73s N/A Link
api-domains-driving-license 0 0 0 23 0 34.81s N/A Link
services-auth-delegation-api 0 0 0 270 0 3m 41.82s 1 decreased (-0.02%) Link

🔻 Code Coverage Decreases vs Default Branch (11)

This report shows up to 5 code coverage decreases.

  • nest-swagger - jest 56.25% (-0.66%) - Details
  • clients-middlewares - jest 75.38% (-0.19%) - Details
  • nest-problem - jest 50.05% (-0.18%) - Details
  • services-sessions - jest 68.66% (-0.1%) - Details
  • services-user-profile - jest 49.19% (-0.07%) - Details

@eirikurn eirikurn force-pushed the feat/add-barcode-session-error branch from 89bd79e to e8f6769 Compare January 24, 2025 10:10
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/native/app/src/ui/lib/card/license-card.tsx (1)

Line range hint 1-319: Consider extracting error handling logic into a custom hook.

While the implementation is solid, consider extracting the error handling logic into a custom hook (e.g., useLicenseError) to improve reusability and maintain separation of concerns.

This would:

  1. Make the error handling logic reusable across components
  2. Simplify testing
  3. Keep the component focused on rendering
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89bd79e and 99af476.

📒 Files selected for processing (4)
  • apps/native/app/src/messages/en.ts (1 hunks)
  • apps/native/app/src/messages/is.ts (1 hunks)
  • apps/native/app/src/screens/wallet-pass/wallet-pass.tsx (1 hunks)
  • apps/native/app/src/ui/lib/card/license-card.tsx (5 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/native/app/src/messages/en.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/native/app/src/screens/wallet-pass/wallet-pass.tsx
  • apps/native/app/src/messages/is.ts
🧰 Additional context used
📓 Path-based instructions (1)
apps/native/app/src/ui/lib/card/license-card.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (2)
apps/native/app/src/ui/lib/card/license-card.tsx (2)

309-311: LGTM! Clear and well-structured error message selection.

The conditional logic for selecting error messages is clean and follows best practices.


11-11: Breaking change: Update error prop type from boolean to ApolloError.

The change in the error prop type from boolean to ApolloError is a breaking change that will require updates in parent components passing the error prop to LicenseCard.

Let's verify the impact on parent components:

Also applies to: 26-29, 130-130

@eirikurn eirikurn added this pull request to the merge queue Jan 25, 2025
Merged via the queue into main with commit f4563ac Jan 25, 2025
132 checks passed
@eirikurn eirikurn deleted the feat/add-barcode-session-error branch January 25, 2025 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants