Skip to content

backend/enh/added-flag-for-runInMasterCloudApi#1395

Merged
sidsethu merged 2 commits into
mainfrom
backend/enh/added-flag-for-runInMasterCloudApi
Jul 2, 2026
Merged

backend/enh/added-flag-for-runInMasterCloudApi#1395
sidsethu merged 2 commits into
mainfrom
backend/enh/added-flag-for-runInMasterCloudApi

Conversation

@H-C-21

@H-C-21 H-C-21 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Adjusted request routing so forwarding happens only when the caller explicitly enables it and the required master configuration (URL and secret) is present.
    • Preserved the existing direct-request behavior when forwarding is disabled or not properly configured.
  • Tests
    • Updated integration coverage to pass the new explicit routing flag when exercising the forwarded request path.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The runThroughMasterCloud function now accepts an additional Bool parameter that, together with the existing configuration checks, decides whether forwarding occurs. The integration test call site now passes the new argument.

Changes

Master Cloud Forward Flag Gating

Layer / File(s) Summary
Add flag parameter and quad-gating logic
lib/mobility-core/src/Kernel/External/MasterCloudForward.hs
Extends runThroughMasterCloud with a new Bool parameter; forwarding now requires shouldForward, the new flag, masterUrl, and masterSecret, with the doc-comment updated to match.
Update integration test call site
lib/mobility-core/test-integration/Main.hs
Passes an explicit trailing True argument to runThroughMasterCloud in the parity test.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A bunny flipped a tiny switch,
And cloudward calls learned when to hitch.
One bool more in the golden chain,
Forward or direct — hop, check again! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title looks like a branch name and doesn’t clearly describe the actual code change. Use a concise, descriptive title such as 'Add caller flag to MasterCloud API forwarding'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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
  • Commit unit tests in branch backend/enh/added-flag-for-runInMasterCloudApi

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

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
lib/mobility-core/src/Kernel/External/MasterCloudForward.hs (1)

140-157: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Breaking shared-kernel API change. This exported function now requires a new positional Bool, so any consumer still calling the old signature will fail to compile. Keep a backward-compatible wrapper/default, or roll this out to every downstream caller in the same release.

🤖 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 `@lib/mobility-core/src/Kernel/External/MasterCloudForward.hs` around lines 140
- 157, The exported runThroughMasterCloud signature now adds a positional Bool,
which breaks existing callers of the shared-kernel API. Update
MasterCloudForward.runThroughMasterCloud to preserve backward compatibility by
keeping the old arity via a wrapper/defaulted overload, or ensure every
downstream call site is updated in the same change; use the function name and
its existing parameters (origBaseUrl, eClient, desc) to locate the affected
code.
🧹 Nitpick comments (1)
lib/mobility-core/src/Kernel/External/MasterCloudForward.hs (1)

151-157: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider a semantic type instead of a bare Bool for flag.

The function already branches on one implicit Bool (shouldForward from env) and now takes a second explicit Bool from the caller. Bare booleans at call sites (e.g., ... "desc" True) are not self-documenting about intent (per the doc-comment, it's meant to gate "city specific forwarder" behavior). A newtype (e.g., CityForwardEnabled Bool) would make call sites clearer and prevent future parameter-order mistakes if more flags are added.

♻️ Example semantic type
+newtype CityForwardEnabled = CityForwardEnabled Bool
+
 runThroughMasterCloud ::
   ...
   Text ->
-  Bool ->
+  CityForwardEnabled ->
   m (Either ClientError a)
-runThroughMasterCloud origBaseUrl eClient desc flag = do
+runThroughMasterCloud origBaseUrl eClient desc (CityForwardEnabled flag) = do
🤖 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 `@lib/mobility-core/src/Kernel/External/MasterCloudForward.hs` around lines 151
- 157, Replace the bare Bool flag in runThroughMasterCloud with a semantic type
so call sites are self-describing and harder to misuse. Introduce a newtype for
the city-specific forwarding toggle (for example around the existing flag
parameter), update the runThroughMasterCloud signature and pattern
matching/guard logic accordingly, and adjust callers to pass the named wrapper
instead of True/False directly.
🤖 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.

Outside diff comments:
In `@lib/mobility-core/src/Kernel/External/MasterCloudForward.hs`:
- Around line 140-157: The exported runThroughMasterCloud signature now adds a
positional Bool, which breaks existing callers of the shared-kernel API. Update
MasterCloudForward.runThroughMasterCloud to preserve backward compatibility by
keeping the old arity via a wrapper/defaulted overload, or ensure every
downstream call site is updated in the same change; use the function name and
its existing parameters (origBaseUrl, eClient, desc) to locate the affected
code.

---

Nitpick comments:
In `@lib/mobility-core/src/Kernel/External/MasterCloudForward.hs`:
- Around line 151-157: Replace the bare Bool flag in runThroughMasterCloud with
a semantic type so call sites are self-describing and harder to misuse.
Introduce a newtype for the city-specific forwarding toggle (for example around
the existing flag parameter), update the runThroughMasterCloud signature and
pattern matching/guard logic accordingly, and adjust callers to pass the named
wrapper instead of True/False directly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5ad89bc7-c08a-4ce6-a1fa-9a6bbf713258

📥 Commits

Reviewing files that changed from the base of the PR and between 60f6ab4 and b165372.

📒 Files selected for processing (2)
  • lib/mobility-core/src/Kernel/External/MasterCloudForward.hs
  • lib/mobility-core/test-integration/Main.hs

@H-C-21 H-C-21 force-pushed the backend/enh/added-flag-for-runInMasterCloudApi branch from b165372 to 6acae38 Compare July 2, 2026 16:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/mobility-core/src/Kernel/External/MasterCloudForward.hs (1)

137-139: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Doc says "quad-gated" but the case-match only checks three conditions.

The updated comment describes forwarding as "Quad-gated: caller flag on + masterUrl set + masterSecret set" — that's only three predicates. The case-match at Line 155 confirms this: case (shouldForward, cfg.masterUrl, cfg.masterSecret) of. If "quad" is meant to include the removed internal getRunApiInMasterCloud check that callers are now expected to fold into their own flag, the comment should say so explicitly — otherwise callers may assume the library still enforces that check internally.

✏️ Suggested doc clarification
--- Drop-in replacement for `@callAPI`@. Quad-gated: caller flag on +
--- masterUrl set + masterSecret set → forwarded. Anything else → direct call.
--- flag is for city specific forwarder.
++-- Drop-in replacement for `@callAPI`@. Triple-gated: caller-supplied
++-- `@shouldForward`@ (callers are responsible for combining this with
++-- 'getRunApiInMasterCloud' and any city-specific check) + masterUrl set
++-- + masterSecret set → forwarded. Anything else → direct call.
🤖 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 `@lib/mobility-core/src/Kernel/External/MasterCloudForward.hs` around lines 137
- 139, Clarify the doc comment for the forwarding logic in MasterCloudForward so
it matches the actual guard checks in the `callAPI`/`case (shouldForward,
cfg.masterUrl, cfg.masterSecret) of` flow. Update the wording to explain that
forwarding is controlled by the caller-provided flag plus `masterUrl` and
`masterSecret`, and explicitly note that the նախկին internal
`getRunApiInMasterCloud` check is no longer enforced here if that is intended.
🤖 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.

Nitpick comments:
In `@lib/mobility-core/src/Kernel/External/MasterCloudForward.hs`:
- Around line 137-139: Clarify the doc comment for the forwarding logic in
MasterCloudForward so it matches the actual guard checks in the `callAPI`/`case
(shouldForward, cfg.masterUrl, cfg.masterSecret) of` flow. Update the wording to
explain that forwarding is controlled by the caller-provided flag plus
`masterUrl` and `masterSecret`, and explicitly note that the նախկին internal
`getRunApiInMasterCloud` check is no longer enforced here if that is intended.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3e8f9db7-cf56-4f10-83ce-f53965bf73fe

📥 Commits

Reviewing files that changed from the base of the PR and between b165372 and 6acae38.

📒 Files selected for processing (2)
  • lib/mobility-core/src/Kernel/External/MasterCloudForward.hs
  • lib/mobility-core/test-integration/Main.hs
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/mobility-core/test-integration/Main.hs

@sidsethu sidsethu merged commit 87033aa into main Jul 2, 2026
2 checks passed
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