Skip to content

SF-3722 Fix errors on format options when no source access#3715

Open
pmachapman wants to merge 1 commit intomasterfrom
fix/SF-3722
Open

SF-3722 Fix errors on format options when no source access#3715
pmachapman wants to merge 1 commit intomasterfrom
fix/SF-3722

Conversation

@pmachapman
Copy link
Collaborator

@pmachapman pmachapman commented Mar 1, 2026

This PR updates the draft USFM format options page to show a warning if the user cannot access the source project, and only allow access to the first chapter.


Open with Devin

This change is Reviewable

@pmachapman pmachapman added the will require testing PR should not be merged until testers confirm testing is complete label Mar 1, 2026
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

// If the user does not have access to the source project, just show chapter 1
this.chaptersWithDrafts = this.translateSource?.texts
.find(t => t.bookNum === bookNum)
?.chapters.map(c => c.number) ?? [initialChapterNum ?? 1];

Choose a reason for hiding this comment

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

🟡 Fallback chapter list uses initialChapterNum from route params instead of always chapter 1

When the user does not have access to the source project, the fallback for chaptersWithDrafts is [initialChapterNum ?? 1]. The code comment on line 295 says "just show chapter 1", but initialChapterNum is captured from route params and could be any chapter number (e.g. 2 from a URL like /format/EXO/2). This means:

Root Cause and Impact

When the user navigates to the format page via a URL with a chapter parameter (e.g. chapter 2), initialChapterNum is set to 2. In the no-source-access case:

this.chaptersWithDrafts = this.translateSource?.texts
  .find(t => t.bookNum === bookNum)
  ?.chapters.map(c => c.number) ?? [initialChapterNum ?? 1];

this.translateSource is null, so chaptersWithDrafts becomes [2] instead of [1]. Furthermore, when the user switches to a different book while still having no source access, initialChapterNum from the original route is reused as the fallback, showing an incorrect chapter for the new book.

The fix should be ?? [1] to match the stated intent of always showing chapter 1 when the user has no source access.

Suggested change
?.chapters.map(c => c.number) ?? [initialChapterNum ?? 1];
?.chapters.map(c => c.number) ?? [1];
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.44%. Comparing base (1822a2f) to head (d75c85c).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3715      +/-   ##
==========================================
- Coverage   81.44%   81.44%   -0.01%     
==========================================
  Files         620      620              
  Lines       38954    38961       +7     
  Branches     6336     6362      +26     
==========================================
+ Hits        31728    31732       +4     
+ Misses       6256     6244      -12     
- Partials      970      985      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pmachapman pmachapman force-pushed the fix/SF-3722 branch 2 times, most recently from 1621063 to 85bde82 Compare March 2, 2026 22:15
@Nateowami
Copy link
Collaborator

Why do we need access to the source in order to show the draft?

@pmachapman
Copy link
Collaborator Author

Why do we need access to the source in order to show the draft?

@Nateowami To get the list of valid chapters for the draft (we can't use the versification to calculate this in the frontend).

@Nateowami
Copy link
Collaborator

Why can't we fetch the draft from the back end and see how many chapters are in it?

@pmachapman
Copy link
Collaborator Author

Why can't we fetch the draft from the back end and see how many chapters are in it?

@Nateowami We retrieve each chapter individually. If we were to fetch the whole draft, we would need a way to parse the USFM and calculate the number of chapters on the frontend. We also can't use the versification to figure out the chapters on the frontend (as is is not present there), so we would likely need some new endpoint just to get the number of chapters. The simplest way is just to see the numbers of chapters in the source USFM, as these should match the chapters drafted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

will require testing PR should not be merged until testers confirm testing is complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants