MOSIP-45003: Fix Handlebars escaping, correct JSON array tags, and add modifySchemaGenerateHbsV2.#1957
Conversation
Signed-off-by: Sradha Mohanty <mohantysradha10@gmail.com>
Signed-off-by: Sradha Mohanty <mohantysradha10@gmail.com>
Signed-off-by: Sradha Mohanty <mohantysradha10@gmail.com>
Signed-off-by: Sradha Mohanty <mohantysradha10@gmail.com>
Signed-off-by: Sradha Mohanty <mohantysradha10@gmail.com>
Signed-off-by: Sradha Mohanty <mohantysradha10@gmail.com>
|
Warning Review limit reached
More reviews will be available in 43 minutes and 7 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesHandlebars Infrastructure and Schema HBS Generation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
`@apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java`:
- Around line 3822-3831: The shared public Handlebars instance disables escaping
(public static Handlebars handlebars = new
Handlebars().with(EscapingStrategy.NOOP)), which breaks escaping for all
templates; restore safe defaults by removing EscapingStrategy.NOOP from the
shared handlebars and instead scope raw output to only where needed: either (A)
change the "json" helper registration to return a Handlebars.SafeString wrapping
gson.toJson(context) so the helper emits unescaped JSON while the rest of the
template remains escaped, or (B) create a separate local Handlebars instance
(e.g., rawHandlebars.with(EscapingStrategy.NOOP)) used only inside
getJsonFromTemplate() when rendering the full JSON template; keep the public
handlebars escaped for general use and reference the existing symbols:
handlebars, getJsonFromTemplate(), the "json" Helper, EscapingStrategy.NOOP, and
gson.
🪄 Autofix (Beta)
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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bcf5c000-1bb8-42f5-8326-f1cfc667d381
📒 Files selected for processing (1)
apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java
Signed-off-by: Sradha Mohanty <mohantysradha10@gmail.com>
There was a problem hiding this comment.
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
`@apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java`:
- Around line 5854-5858: The code assumes updateIdentityHbs(regenerateHbs)
returns a JSON with a "request" object which can be missing; in AdminTestUtil
where you build requestJson from hbs and call
requestJson.getJSONObject("request").put("verifiedAttributes",
"$VERIFIED_ATTRIBUTES$"), add a structural guard: parse hbs into JSONObject,
check containsKey("request") and that get("request") is a JSONObject (or not
null); if the guard fails, throw a clear RuntimeException/IllegalStateException
(or propagate the original error) with a descriptive message including hbs and
regenerateHbs context so callers fail fast instead of hitting JSONException
during mutation. Ensure the check is performed immediately after creating
requestJson and before any put() call.
🪄 Autofix (Beta)
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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0020840a-755b-4974-a036-f3f0ef9d4280
📒 Files selected for processing (2)
apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.javaapitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java
✅ Files skipped from review due to trivial changes (1)
- apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java
Signed-off-by: Sradha Mohanty <mohantysradha10@gmail.com>
Summary by CodeRabbit