Skip to content

#2560 fix: ensure consistent exception propagation in ImmutableDocument duing lazy loading #2562

Merged
robfrank merged 2 commits intomainfrom
fix/2560-immutable-document-lazy-loading-exception
Sep 28, 2025
Merged

#2560 fix: ensure consistent exception propagation in ImmutableDocument duing lazy loading #2562
robfrank merged 2 commits intomainfrom
fix/2560-immutable-document-lazy-loading-exception

Conversation

@robfrank
Copy link
Collaborator

This pull request addresses an inconsistency in the lazy loading behavior of the ImmutableDocument class, specifically ensuring that the get() method now properly propagates exceptions thrown during lazy loading, just like other related methods. This fix improves the reliability of permission checks and exception handling in workflows that depend on consistent error propagation. Additionally, comprehensive tests have been added to verify the fix and ensure consistent behavior across various scenarios.

Lazy loading consistency and exception propagation

  • The get() method in ImmutableDocument was updated to propagate exceptions thrown during lazy loading, aligning its behavior with other methods such as has(), modify(), toJSON(), toMap(), and getPropertyNames(). This ensures that permission checks and security workflows relying on exceptions now work correctly with get().

Test coverage for lazy loading and exception handling

  • Added a new test class ImmutableDocumentLazyLoadingInconsistencyTest to verify consistent exception propagation for the get() method and other related methods. The tests cover scenarios with and without security exceptions, and check propagation of different exception types.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @robfrank, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an inconsistency in the ImmutableDocument class where the get() method was not properly propagating exceptions during lazy loading, unlike other related methods. The change ensures that any exceptions encountered during the lazy loading process are now correctly thrown, which is crucial for maintaining the integrity of permission checks and error handling mechanisms. The update is supported by new, comprehensive tests that validate the consistent behavior across different exception types and scenarios.

Highlights

  • Consistent Exception Propagation: The get() method in ImmutableDocument now consistently propagates exceptions thrown during lazy loading, aligning its behavior with other methods like has(), modify(), toJSON(), toMap(), and getPropertyNames().
  • Improved Reliability: This fix enhances the reliability of permission checks and security workflows that depend on exceptions being thrown during lazy loading.
  • Comprehensive Test Coverage: A new test class, ImmutableDocumentLazyLoadingInconsistencyTest, has been added to thoroughly verify the consistent exception propagation across various scenarios, including security exceptions and different exception types.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an inconsistency in exception propagation for the ImmutableDocument.get() method during lazy loading, aligning its behavior with other methods. The change is straightforward and effective. The new tests are comprehensive, verifying the fix across various scenarios. I've provided a couple of suggestions to enhance code clarity and maintainability by removing redundant code in both the implementation and the new tests.

@codacy-production
Copy link

codacy-production bot commented Sep 28, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-1.11% 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9c8ae17) 72462 45661 63.01%
Head commit (b5c5e62) 72462 (+0) 44860 (-801) 61.91% (-1.11%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#2562) 1 1 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@robfrank robfrank merged commit 340426c into main Sep 28, 2025
6 of 7 checks passed
@robfrank robfrank deleted the fix/2560-immutable-document-lazy-loading-exception branch September 28, 2025 18:44
robfrank added a commit that referenced this pull request Nov 10, 2025
…nt during lazy loading (#2562)

(cherry picked from commit 340426c)
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.

2 participants