Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[dashboard] Fix JSONPath crash on Tenant details with resourceQuotas#2249

Open
sircthulhu wants to merge 2 commits intomaincozystack/cozystack:mainfrom
fix/dashboard-flatmap-jsonpath-crashcozystack/cozystack:fix/dashboard-flatmap-jsonpath-crashCopy head branch name to clipboard
Open

[dashboard] Fix JSONPath crash on Tenant details with resourceQuotas#2249
sircthulhu wants to merge 2 commits intomaincozystack/cozystack:mainfrom
fix/dashboard-flatmap-jsonpath-crashcozystack/cozystack:fix/dashboard-flatmap-jsonpath-crashCopy head branch name to clipboard

Conversation

@sircthulhu
Copy link
Contributor

@sircthulhu sircthulhu commented Mar 19, 2026

What this PR does

Fixes a crash on the Tenant details page when resourceQuotas are configured. The dashboard renders a ResourceQuota table with a "Used" column that references $.status.used[_flatMapData_Key]. When the flatMap placeholder is not resolved during initial render, the raw placeholder is passed to the JSONPath parser, causing:

Parse error on line 1: $.status.used[_flatMapData_Key]
Expecting 'STAR', 'SCRIPT_EXPRESSION', 'INTEGER', ... got 'IDENTIFIER'

The original flatmap-dynamic-key.diff patch that handled this was removed during the 1.4.0 dashboard upgrade, assuming upstream included the fix. Upstream adopted the code reordering (flatMap expansion before customFields resolution) but not the fallback protection for unresolved placeholders.

Adds a patch to openapi-k8s-toolkit that checks for unresolved _flatMap*_Key placeholders after regex substitution and returns null instead of calling jp.query() with an invalid expression.

Release note

[dashboard] Fix crash on Tenant details page when resourceQuotas are configured

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of unresolved data fields in table displays, preventing errors when field values cannot be properly resolved.

…ders

When viewing Tenant details with resourceQuotas, the "Used" column
references $.status.used[_flatMapData_Key]. If the flatMap placeholder
is not resolved (key missing from expanded row), the raw placeholder
is passed to the JSONPath parser which crashes with a parse error.

The original flatmap-dynamic-key.diff patch that handled this was
removed during the 1.4.0 upgrade, assuming upstream included the fix.
Upstream adopted the reordering (flatMap before customFields) but not
the fallback protection.

Add a patch that checks for unresolved _flatMap*_Key placeholders
after regex substitution and returns null instead of calling jp.query()
with an invalid expression.

Assisted-By: Claude AI
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5fea601b-7e8a-4dc2-ace4-5383cd573446

📥 Commits

Reviewing files that changed from the base of the PR and between f1ba62d and c7509ab.

📒 Files selected for processing (1)
  • packages/system/dashboard/images/openapi-ui/openapi-k8s-toolkit/patches/flatmap-unresolved-placeholder.diff

📝 Walkthrough

Walkthrough

A conditional guard was added to JSONPath querying in EnrichedTableProvider utilities that skips query execution when an unresolved placeholder pattern is detected, setting fieldValue to null instead. Existing query and normalization logic is preserved for other cases.

Changes

Cohort / File(s) Summary
JSONPath Query Guard
packages/system/dashboard/images/openapi-ui/openapi-k8s-toolkit/patches/flatmap-unresolved-placeholder.diff
Added conditional logic to detect and handle unresolved _flatMap..._Key placeholders by bypassing JSONPath querying and normalizing results appropriately.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes


🐰 A placeholder once caused dismay,
But a guard clause has saved the day!
When flatMap keys refuse to resolve,
We skip the query—a neat fix to solve! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: fixing a JSONPath crash on Tenant details when resourceQuotas are configured, which directly corresponds to the patch that prevents JSONPath parser errors from unresolved flatMap placeholders.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dashboard-flatmap-jsonpath-crash
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the dashboard's Tenant details page, preventing a crash that occurred when resource quotas were present. The fix involves enhancing the JSONPath resolution logic to gracefully handle cases where dynamic placeholders remain unresolved, ensuring the application's stability and a smoother user experience.

Highlights

  • JSONPath Crash Fix: Resolved a crash occurring on the Tenant details page when resourceQuotas were configured, caused by invalid JSONPath expressions due to unresolved _flatMapData_Key placeholders.
  • Placeholder Handling: Introduced a new patch to openapi-k8s-toolkit that checks for unresolved _flatMap*_Key placeholders and returns null instead of attempting to parse an invalid JSONPath expression.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 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 counter productive. 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.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 aims to fix a crash on the Tenant details page. While the approach is correct, the implemented patch contains a regular expression with a syntax error that will cause the application to crash. I've provided a critical review comment with a corrected and more robust version of the regular expression that fixes the syntax error and makes the check more specific to the issue at hand.

}
- const jpQueryResult = jp.query(el, `$${resolvedJsonPath}`)
- fieldValue = Array.isArray(jpQueryResult) && jpQueryResult.length === 1 ? jpQueryResult[0] : jpQueryResult
+ if (/_flatMap[^[\]]+_Key/.test(resolvedJsonPath)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This regular expression contains a syntax error and will cause the application to fail. The character class [^[[]] is invalid in JavaScript. To create a character class that matches any character except for [ or ], you must escape the brackets, like this: [^\[\]].

Additionally, to make this check more robust, it's better to match the specific pattern [<placeholder>] that causes the JSONPath parser to crash, rather than just the placeholder name itself. This avoids potential false positives.

The following suggestion corrects the syntax and makes the check more specific.

            if (/\S*\_flatMap[^[\]]+_Key\S*/.test(resolvedJsonPath)) {

Use [^\]]+ (same as existing code in utils.ts) instead of [^[\]]+ for
consistency.

Assisted-By: Claude AI
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
@sircthulhu sircthulhu marked this pull request as ready for review March 19, 2026 12:32
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.