Skip to content

Conversation

@TylerZeroMaster
Copy link

https://openstax.atlassian.net/browse/CORE-1521

The idea is that we will use partial_data to determine if there was an error. If there was an error, we can cache less greedily.

I tried to do this in a way that wouldn't break things that do not care about partial data. It's maybe a little hacky...

Next I plan to update content.rb in exercises so that it sets the cache expiration to 30 minutes if partial_data is true.

The idea is that we will use partial_data to determine if there was an error. If there was an error, we can cache less greedily.
@TylerZeroMaster
Copy link
Author

TylerZeroMaster commented Jan 27, 2026

It might also make sense for it to look at the previous content version, not just previous archive version. I think in most cases the page slugs will remain the same between content versions. This would still potentially cause some context tags to be removed if the slugs are not the same between versions, but I think it would be very rare.

The ABL keeps two versions when someone adds a new version: the version that is currently on REX (if there is one), and the new version they add.

Edit: It already does this.

hash[page.uuid] ||= []
hash[page.uuid] << { book: book.slug, page: page.slug }
end
rescue StandardError => exception
Copy link
Member

Choose a reason for hiding this comment

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

Hmm the issue is that this rescue will prevent the rescue in https://github.com/openstax/content-ruby/blob/main/lib/openstax/content/abl.rb#L57 from triggering, so we'll lose the behavior of trying old archive versions.

Maybe this logic has to replace the raise exception in https://github.com/openstax/content-ruby/blob/main/lib/openstax/content/abl.rb#L58 and https://github.com/openstax/content-ruby/blob/main/lib/openstax/content/abl.rb#L66 instead?

Copy link
Author

Choose a reason for hiding this comment

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

Oh, you're right. I think I got in too big of a hurry on this one. I will fix it.

Copy link
Author

Choose a reason for hiding this comment

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

@Dantemss I moved the error handling into each_book_with_previous_archive_version_fallback and changed it so that it tries with the newest archive version each time, and walks backwards up to max_attempts for each book.

Before it would reuse the same previous_archive for subsequent books, and only fail up to max_attempts for all books.

…eful degradation

The changes fix a critical bug and significantly improve error handling.

Key improvements:

1. Each book now gets its own previous_version and previous_archive instead of reusing the first failing book's archive for all subsequent failures
2. Replace complex batch retry pattern with straightforward per-book retry loop
3. New allow_partial_data parameter allows processing to continue when books fail, logging warnings instead of raising exceptions
4. Remove duplicate try/catch from slugs_by_page_uuid, consolidate in each_book_with_previous_archive_version_fallback
5. Add proper test setup with mocked books to verify graceful degradation and partial data handling
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.

3 participants