Skip to content

Conversation

@conroy-ricketts
Copy link
Contributor

@conroy-ricketts conroy-ricketts commented Jan 23, 2026

CCCT-2018

Technical Summary

I added logic to parse release toggles for the start_configuration API call.

Important note - Since the Connect DB is not available during parsing for the start_configuration API call, and the ConnectReleaseTogglesParser.parse() function currently requires a response code and an input object, I opted to not reuse the ConnectReleaseTogglesParser and instead parse the toggles separately in StartConfigurationResponseParser while storing the toggles in the PersonalIdSessionData for storage in the Connect DB later during successful user account recovery. Let me know if there is a better approach to take here.

Edit: I tweaked ConnectReleaseToggleRecord to treat the date fields as optional and added a new unit test for that accordingly.

Safety Assurance

Safety story

I verified that release toggles are being parsed correctly for the start_configuration API call and stored in PersonalIdSessionData correctly.

I also verified that the release toggles are stored correctly in the Connect DB after successful account recovery.

Automated test coverage

I added some basic stuff for unit testing the release toggles with the session data in StartConfigurationResponseParserTest. I did not go too crazy with the unit tests considering that we already have all the tests in ConnectReleaseTogglesParserTest. Let me know if I should add more tests for StartConfigurationResponseParserTest.

I verified that all the unit tests ran successfully with my changes.

QA Plan

No action needed from QA on this ticket. I'm sure this will all be tested thoroughly via other tickets.

Parsed feature release toggles from inside StartConfigurationResponseParser and stored the toggles in PersonalIdSessionData.
Stored feature release toggles in the Connect DB upon successful user account recovery.
…nto task/CCCT-2018-parse-release-toggles-when-start-configuration
Updated unit tests in StartConfigurationResponseParserTest.

Added some null safety.
@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

This PR adds support for feature release toggles in the CommCare Connect authentication flow. Changes include: adding a nullable featureReleaseToggles field to PersonalIdSessionData, parsing toggles from the start configuration API response, persisting toggles to the database during account recovery, and adding tests to verify toggle parsing from JSON with date field handling.

Sequence Diagram

sequenceDiagram
    participant Server as Start Configuration<br/>API Server
    participant Parser as StartConfiguration<br/>ResponseParser
    participant Session as PersonalIdSessionData
    participant Fragment as PersonalIdBackupCode<br/>Fragment
    participant DB as ConnectAppDatabaseUtil

    Server->>Parser: Return response with toggles JSON
    Parser->>Parser: Parse toggles to List<ConnectReleaseToggleRecord>
    Parser->>Session: Assign featureReleaseToggles
    Fragment->>Session: Retrieve featureReleaseToggles
    alt Toggles present
        Fragment->>DB: storeReleaseToggles(toggles)
        DB->>DB: Persist to database
    else Toggles null
        Fragment->>Fragment: Skip storage
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • CCCT-2016 Create Release Toggles DB Table #3482 — Main PR that adds parsing, session field, and persistence usage for ConnectReleaseToggleRecord which directly depends on and complements this PR's toggle handling.
  • CCCT-2017 Release Toggles Parser #3498 — Introduces and wires up feature release toggles with the same ConnectReleaseToggleRecord model, parser-related code paths, and ConnectAppDatabaseUtil.storeReleaseToggles utility.
  • Backup Code page redirection #3137 — Modifies the same classes (PersonalIdSessionData and PersonalIdBackupCodeFragment), touching the same session-data model and recovery fragment.

Suggested labels

skip-integration-tests

Suggested reviewers

  • OrangeAndGreen
  • shubham1g5
  • Jignesh-dimagi
  • jaypanchal-13
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: parsing release toggles during start configuration, which is the core objective of the PR.
Description check ✅ Passed The pull request description covers the technical summary, implementation rationale, safety assurance with testing details, and QA plan. However, it lacks a product description section and does not address all the checklist items regarding labels.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch task/CCCT-2018-parse-release-toggles-when-start-configuration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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

🤖 Fix all issues with AI agents
In
`@app/src/org/commcare/connect/network/connectId/parser/StartConfigurationResponseParser.java`:
- Around line 33-38: The parser currently leaves the previous feature toggles
intact when the "toggles" field is omitted; update
StartConfigurationResponseParser so that when featureReleaseTogglesJson is null
you explicitly clear overwriting state by calling
sessionData.setFeatureReleaseToggles(...) with an empty list (instead of doing
nothing). Locate the block using featureReleaseTogglesJson,
ConnectReleaseToggleRecord.Companion.releaseTogglesFromJson and
sessionData.setFeatureReleaseToggles and add the else branch that sets an empty
list to avoid stale toggles persisting across parses.

Cleared release toggles when null for the PersonalIdSessionData.
Moved logic for storing release toggles to PersonalIdMessageFragment.
Tweaked ConnectReleaseToggleRecord so that the date fields are optional, and also reflected that in a new unit test.
@shubham1g5 shubham1g5 added the skip-integration-tests Skip android tests. label Jan 23, 2026
shubham1g5
shubham1g5 previously approved these changes Jan 23, 2026
Added one more assertion to new unit test.
Abstracted some json logic to ConnectReleaseToggleRecord.releaseTogglesFromJson().
Added handling for the case that toggles are missing from response json.
shubham1g5
shubham1g5 previously approved these changes Jan 23, 2026
@conroy-ricketts conroy-ricketts merged commit 1a74ef7 into master Jan 23, 2026
8 checks passed
@conroy-ricketts conroy-ricketts deleted the task/CCCT-2018-parse-release-toggles-when-start-configuration branch January 23, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-integration-tests Skip android tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants