Skip to content

dataconnect(change): Add @SubclassOptInRequired(InternalForInheritanceFirebaseApi) to public interfaces - #8603

Open
dconeybe wants to merge 8 commits into
mainfrom
dconeybe/dataconnect/SubclassOptInRequired
Open

dconeybe wants to merge 8 commits into
mainfrom
dconeybe/dataconnect/SubclassOptInRequired

Conversation

@dconeybe

@dconeybe dconeybe commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

This pull request adds the @SubclassOptInRequired(InternalForInheritanceFirebaseApi::class) annotation to public interfaces in the firebase-dataconnect module. This change explicitly discourages third-party library consumers from inheriting these interfaces, as their contracts may be expanded or altered in future releases.

Additionally, it introduces the InternalForInheritanceFirebaseApi annotation to firebase-annotations to enforce the opt-in requirement, and updates the firebase-dataconnect dependency configuration so that consumers can transitively access this annotation at compile time.

Googlers can see the API proposal at go/data-connect-subclass-optin-kotlin-api-proposal

Highlights

  • Interface Protection: Added @SubclassOptInRequired(InternalForInheritanceFirebaseApi::class) to public API interfaces in firebase-dataconnect (such as FirebaseDataConnect, QueryRef, MutationRef, QuerySubscription, and their related options and results) to prevent unintended external extension.
  • New Annotation: Introduced the InternalForInheritanceFirebaseApi annotation inside firebase-annotations to support the opt-in logic for the firebase-dataconnect module.
  • Dependency Adjustment: Changed the firebase-annotations dependency from implementation to api in firebase-dataconnect.gradle.kts so that InternalForInheritanceFirebaseApi is available transitively, satisfying compilation requirements for consumers.
Changelog
  • CHANGELOG.md (in firebase-annotations)
    • Classified the addition of InternalForInheritanceFirebaseApi as a new feature instead of a regular change.
  • api.txt (in firebase-annotations)
    • Updated to include the InternalForInheritanceFirebaseApi public API signature.
  • firebase-annotations.gradle.kts
    • Minor version/metadata updates.
  • gradle.properties (in firebase-annotations)
    • Increment properties configuration.
  • InternalForInheritanceFirebaseApi.kt
    • New file introducing the InternalForInheritanceFirebaseApi annotation.
  • CHANGELOG.md (in firebase-dataconnect)
    • Updated with the PR number.
  • api.txt (in firebase-dataconnect)
    • Tracked the @SubclassOptInRequired usages on public interfaces.
  • firebase-dataconnect.gradle.kts
    • Exported firebase-annotations dependency as api.
  • gradle.properties (in firebase-dataconnect)
    • Increment properties configuration.
  • DataConnectOperationFailureResponse.kt
    • Added @SubclassOptInRequired to the DataConnectOperationFailureResponse interface.
  • FirebaseDataConnect.kt
    • Added @SubclassOptInRequired to FirebaseDataConnect, QueryRefOptionsBuilder, and MutationRefOptionsBuilder.
  • MutationRef.kt
    • Added @SubclassOptInRequired to MutationRef and MutationResult.
  • OperationRef.kt
    • Added @SubclassOptInRequired to OperationRef and OperationResult.
  • QueryRef.kt
    • Added @SubclassOptInRequired to QueryRef and QueryResult.
  • QuerySubscription.kt
    • Added @SubclassOptInRequired to QuerySubscription and QuerySubscriptionResult.

…ceFirebaseApi)` to public interfaces

Googlers see go/data-connect-subclass-optin-kotlin-api-proposal
@gemini-code-assist

Copy link
Copy Markdown
Contributor
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 the 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 counterproductive. 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.

@github-actions

Copy link
Copy Markdown
Contributor

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

@dconeybe

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 introduces a new annotation, InternalForInheritanceFirebaseApi, in the firebase-annotations module, which is used to mark classes and interfaces that should not be inherited or implemented outside of the Firebase SDK. In the firebase-dataconnect module, this annotation is applied via @SubclassOptInRequired to several public interfaces (such as FirebaseDataConnect, OperationRef, QueryRef, and others) to explicitly prevent external subclassing. Additionally, build configurations and dependencies have been updated to support this Kotlin opt-in mechanism, and the project versions have been bumped accordingly. There are no review comments, and I have no additional feedback to provide.

…ebaseApi addition as feature

Update the changelog entry for adding InternalForInheritanceFirebaseApi from [changed] to [feature]. Adding a new public annotation to the library introduces new capability and public API surface rather than modifying existing behavior, so it should be categorized as a feature.
Change the dependency on :firebase-annotations from implementation to api in firebase-dataconnect.gradle.kts. Since firebase-dataconnect exposes @SubclassOptInRequired(InternalForInheritanceFirebaseApi::class) on its public interfaces, consumers require access to InternalForInheritanceFirebaseApi transitively at compile time.
@dconeybe
dconeybe marked this pull request as ready for review September 15, 2026 20:59
@dconeybe
dconeybe requested a review from rlazo September 15, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant