Skip to content

Remove app's registration/ recovery flow when it's disabled - #4840

Merged
ThaminduDilshan merged 1 commit into
thunder-id:mainfrom
ThaminduDilshan:thamindu-fixes
Aug 11, 2026
Merged

Remove app's registration/ recovery flow when it's disabled#4840
ThaminduDilshan merged 1 commit into
thunder-id:mainfrom
ThaminduDilshan:thamindu-fixes

Conversation

@ThaminduDilshan

@ThaminduDilshan ThaminduDilshan commented Aug 11, 2026

Copy link
Copy Markdown
Member

Purpose

This pull request updates the handling of registration and recovery flow bindings in the inbound client service to ensure that disabled flows do not retain or persist stale flow IDs, and that auto-filling of registration/recovery flows is prevented when the enable flag is false. It also adds and updates tests to validate these behaviors.

Approach

Flow binding logic improvements:

  • In resolveFlowDefaults, registration and recovery flow IDs are now proactively cleared if their enable flags are false, and resolution for these flows is skipped in this case. This prevents persisting IDs that contradict the disabled state. [1] [2] [3] [4]
  • In walkReferencedFlows, the service no longer auto-fills registration or recovery flow IDs when they are missing and the enable flag is false, ensuring no phantom configuration is created. Only sign-out flows are auto-filled if missing.

Test updates and additions:

  • Updated tests to ensure that registration/recovery flow resolution is skipped when the enable flag is false, and that flow IDs are cleared in these cases. [1] [2]
  • Added tests to verify that creating or updating an inbound client with a disabled registration or recovery flow clears the corresponding flow ID.
  • Updated reconciliation tests to ensure that missing registration/recovery flows are not auto-filled when disabled.
  • Adjusted error handling tests to reflect the new resolution logic and flow enablement checks.

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
    • Ran Vale and fixed all errors and warnings
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • Bug Fixes
    • Disabled registration and recovery flows now clear stale flow references.
    • Disabled flows no longer receive unintended default assignments.
    • Missing registration and recovery bindings remain empty instead of being automatically filled.
    • Sign-out flow handling continues to work independently.
    • Incomplete client configurations are handled without errors.

@ThaminduDilshan ThaminduDilshan added Type/Bug trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes labels Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The inbound-client service now clears disabled registration and recovery flow IDs, resolves those flows only when enabled, disables flows with empty resolutions, and limits referenced-flow auto-fill to sign-out bindings. Unit and integration tests cover resolution, persistence, errors, and reconciliation.

Changes

Inbound flow binding handling

Layer / File(s) Summary
Conditional flow resolution
backend/internal/inboundclient/service.go, backend/internal/inboundclient/service_test.go
resolveFlowDefaults handles nil clients, clears disabled registration and recovery IDs, and resolves those flows only when enabled. Empty resolved IDs disable the related flags. Tests cover skipped resolution and error ordering.
Persisted binding cleanup
backend/internal/inboundclient/service_test.go, tests/integration/application/application_api_test.go
Create and update tests verify that disabled registration or recovery bindings persist empty flow IDs.
Referenced-flow reconciliation
backend/internal/inboundclient/service.go, backend/internal/inboundclient/service_test.go, tests/integration/application/flow_reference_validation_test.go
Reconciliation no longer auto-fills missing registration or recovery bindings. Sign-out auto-fill remains enabled. Tests cover creation, updates, disabled bindings, and enabled-flow mismatches.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: senthalan, malith-19, rajithacharith

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: clearing registration and recovery flow IDs when those flows are disabled.
Description check ✅ Passed The description follows the template, explains the purpose and approach, identifies the related issue, and summarizes the test updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/internal/inboundclient/service.go`:
- Around line 611-621: Update docs/content/apis.mdx to document the behavior at
backend/internal/inboundclient/service.go:611-621, where disabled registration
or recovery bindings clear persisted flow IDs; at 657-677, where enabled flows
are disabled if no effective flow resolves; and at 1887-1894, where
reconciliation only auto-fills sign-out bindings. Cover all three service.go
sites in the relevant API documentation.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 71767879-aa26-41c9-aaac-816841aec4af

📥 Commits

Reviewing files that changed from the base of the PR and between 88727ff and acf588e.

📒 Files selected for processing (2)
  • backend/internal/inboundclient/service.go
  • backend/internal/inboundclient/service_test.go

Comment on lines +611 to +621
// Drop registration/recovery bindings whose enable flag is false before any resolution so we
// never persist an ID that contradicts the toggle. This must run regardless of whether flowMgt
// is wired — persistence should still respect the caller's disabled intent.
if !c.IsRegistrationFlowEnabled {
c.RegistrationFlowID = ""
}
if !c.IsRecoveryFlowEnabled {
c.RecoveryFlowID = ""
}

if s.flowMgt == nil {

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🔴 Documentation Required
This PR introduces user-facing changes that are not covered by documentation updates under docs/.
Please update the relevant documentation before merging.

Missing documentation:

  • backend/internal/inboundclient/service.go#L611-L621: Document that disabled registration and recovery bindings clear persisted flow IDs in docs/content/apis.mdx.
  • backend/internal/inboundclient/service.go#L657-L677: Document that enabled registration and recovery flows are disabled when no effective flow resolves in docs/content/apis.mdx.
  • backend/internal/inboundclient/service.go#L1887-L1894: Document that reconciliation only auto-fills sign-out bindings in docs/content/apis.mdx.

As per path instructions: “If ANY of the above are detected … post a single consolidated PR-level comment.”

📍 Affects 1 file
  • backend/internal/inboundclient/service.go#L611-L621 (this comment)
  • backend/internal/inboundclient/service.go#L657-L677
  • backend/internal/inboundclient/service.go#L1887-L1894
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/internal/inboundclient/service.go` around lines 611 - 621, Update
docs/content/apis.mdx to document the behavior at
backend/internal/inboundclient/service.go:611-621, where disabled registration
or recovery bindings clear persisted flow IDs; at 657-677, where enabled flows
are disabled if no effective flow resolves; and at 1887-1894, where
reconciliation only auto-fills sign-out bindings. Cover all three service.go
sites in the relevant API documentation.

Source: Path instructions

@ThaminduDilshan ThaminduDilshan added trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes and removed trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes labels Aug 11, 2026
thiva-k
thiva-k previously approved these changes Aug 11, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/integration/application/application_api_test.go (1)

3636-3657: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🔴 Documentation Required

This PR introduces user-facing changes that are not covered by documentation updates under docs/.
Please update the relevant documentation before merging.

Missing documentation:

  • Application API flow bindings: document disabled registration and recovery bindings, conditional flow-ID resolution, and empty-ID persistence in docs/content/apis.mdx.
  • Flow reference reconciliation: document that registration and recovery bindings are not auto-filled, while sign-out bindings remain auto-filled. Update docs/content/guides/applications/application-settings.mdx.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/application/application_api_test.go` around lines 3636 -
3657, Update docs/content/apis.mdx to document disabled registration and
recovery bindings, conditional flow-ID resolution, and persistence of empty flow
IDs. Update docs/content/guides/applications/application-settings.mdx to clarify
that registration and recovery bindings are not auto-filled, while sign-out
bindings remain auto-filled.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/integration/application/flow_reference_validation_test.go`:
- Around line 29-32: Update docs/content/apis.mdx to document disabled
registration and recovery binding persistence, enabled binding mismatch
rejection, and the related application API fields. Update
docs/content/guides/inbound-client-flow-bindings.mdx to clarify that disabled
registration and recovery bindings are not auto-filled while sign-out bindings
remain auto-filled, matching the contract described near the
registration/recovery flow validation test.

---

Outside diff comments:
In `@tests/integration/application/application_api_test.go`:
- Around line 3636-3657: Update docs/content/apis.mdx to document disabled
registration and recovery bindings, conditional flow-ID resolution, and
persistence of empty flow IDs. Update
docs/content/guides/applications/application-settings.mdx to clarify that
registration and recovery bindings are not auto-filled, while sign-out bindings
remain auto-filled.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 68299aaa-3717-4b48-9a17-7d1104eeeaf0

📥 Commits

Reviewing files that changed from the base of the PR and between acf588e and 98c53fe.

📒 Files selected for processing (2)
  • tests/integration/application/application_api_test.go
  • tests/integration/application/flow_reference_validation_test.go

Comment on lines +29 to +32
// REGISTRATION / RECOVERY flow via a CALL node, the app must either declare a matching binding
// (with the corresponding enable flag on) or leave it disabled — in the disabled case the server
// persists an empty binding regardless of what the auth flow calls. Sign-out still auto-fills
// because it has no enable toggle. Genuine mismatches with an enabled binding still reject.

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🔴 Documentation Required
This PR introduces user-facing changes that are not covered by documentation updates under docs/.
Please update the relevant documentation before merging.

Missing documentation:

  • docs/content/apis.mdx: Document disabled registration and recovery binding persistence, enabled mismatch rejection, and the related application API fields.
  • docs/content/guides/inbound-client-flow-bindings.mdx: Document that disabled registration and recovery bindings are not auto-filled, while sign-out bindings remain auto-filled.

Changed-contract anchor:

  • tests/integration/application/flow_reference_validation_test.go#L29-L32: This range records the user-facing reconciliation contract that requires documentation.

As per path instructions, user-facing behavior changes require corresponding updates under docs/.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/application/flow_reference_validation_test.go` around lines
29 - 32, Update docs/content/apis.mdx to document disabled registration and
recovery binding persistence, enabled binding mismatch rejection, and the
related application API fields. Update
docs/content/guides/inbound-client-flow-bindings.mdx to clarify that disabled
registration and recovery bindings are not auto-filled while sign-out bindings
remain auto-filled, matching the contract described near the
registration/recovery flow validation test.

Source: Path instructions

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/internal/inboundclient/service.go 90.90% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@ThaminduDilshan
ThaminduDilshan added this pull request to the merge queue Aug 11, 2026
Merged via the queue into thunder-id:main with commit 97b7b08 Aug 11, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trigger-pr-builder Add when the PR is ready for CI; starts the PR Builder for this and all later pushes Type/Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

APP-1039 flow-mismatch error raised for applications with no recovery/registration flows configured.

2 participants