Skip to content

Add JSON query expressions +semver: minor#218

Merged
guibranco merged 1 commit into
guibranco:mainfrom
nimble-turtle:json-query-expression
May 5, 2026
Merged

Add JSON query expressions +semver: minor#218
guibranco merged 1 commit into
guibranco:mainfrom
nimble-turtle:json-query-expression

Conversation

@nimble-turtle

@nimble-turtle nimble-turtle commented May 5, 2026

Copy link
Copy Markdown
Contributor

📑 Description

Slight change to allow jquery expressions instead of just jquery paths on the JSON.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

☢️ Does this introduce a breaking change?

  • Yes
  • No

Summary by Sourcery

Extend dynamic JSON querying to support full JSONPath filter expressions and update documentation and tests accordingly.

New Features:

  • Allow JSON filter expressions (including predicates) in dynamic JSON queries using jsonpath-ng extended parsing.

Enhancements:

  • Clarify query parameter behavior and examples in code comments and README for dynamic JSON endpoints.

Tests:

  • Add tests covering successful and failing dynamic JSON queries using JSONPath filter expressions.

Summary by CodeRabbit

  • New Features

    • Added support for JSONPath filter expressions in the /dynamic/json/ endpoint, enabling more flexible data selection using sibling field matching instead of hardcoded indices.
  • Documentation

    • Updated documentation to clarify accepted query parameter formats (JSONPath and dot-path notation) with improved examples.
  • Tests

    • Added test coverage for JSONPath filter expression functionality, including successful matches and error cases.

@vercel

vercel Bot commented May 5, 2026

Copy link
Copy Markdown

@nimble-turtle is attempting to deploy a commit to the guibranco's projects Team on Vercel.

A member of the Team first needs to authorize it.

@sourcery-ai

sourcery-ai Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Extends dynamic JSON querying to support full jsonpath-ng expressions (including filter expressions) by switching to the extended parser, adds coverage for filter-based selection behavior, and documents the new query capabilities.

Sequence diagram for dynamic JSON progress query with filter expressions

sequenceDiagram
  actor Client
  participant FlaskApp as Flask_app
  participant View as get_progress_svg_dynamic_json
  participant Normalizer as normalize_jsonpath_query
  participant HTTP as Remote_JSON_service
  participant JSONPath as jsonpath_ng_ext_parse

  Client->>FlaskApp: HTTP GET /progress.svg?url=...&query=$.progress[?(@.data.language.name=='Spanish')].data.translationProgress
  FlaskApp->>View: Dispatch request
  View->>HTTP: Fetch JSON from url
  HTTP-->>View: JSON document
  View->>Normalizer: normalize_jsonpath_query(selector)
  Normalizer-->>View: normalized JSONPath expression
  View->>JSONPath: parse(normalized_expression)
  JSONPath-->>View: Compiled JSONPath with filter support
  View->>View: Apply JSONPath to JSON document
  View->>FlaskApp: Render SVG with extracted progress value
  FlaskApp-->>Client: SVG response
Loading

File-Level Changes

Change Details Files
Enable full jsonpath-ng expressions (including filters) for dynamic JSON queries.
  • Switch JSONPath parser import to use jsonpath_ng.ext.parse so filter expressions are accepted.
  • Clarify normalize_jsonpath_query docstring to distinguish between root-prefixed JSONPath and simple dot/index selectors, adding an example with a filter expression.
  • Update get_progress_svg_dynamic_json docstring to describe support for filter expressions in addition to plain paths.
app.py
Add tests for filter-expression JSON queries and non-match behavior.
  • Add test that exercises a JSONPath filter expression selecting an entry by language name and verifying the extracted progress value.
  • Add test that verifies a filter expression with no matches causes the dynamic JSON endpoint to return HTTP 422.
test_api.py
Document support for JSONPath filter expressions in the public API.
  • Expand README description of the query parameter to describe filter expression support and provide an example that looks up a value by sibling field instead of index.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The PR extends JSONPath support in the JSON URL route to include full filter expressions (using jsonpath_ng.ext), updating the imports, documenting the capability in docstrings and README, and adding two test cases to verify filter behavior and error handling.

Changes

JSONPath Filter Expression Support

Layer / File(s) Summary
Dependency & Import Update
app.py
JSONPath parsing switched from jsonpath_ng to jsonpath_ng.ext.parse to enable filter expression support.
Documentation & Implementation
app.py
normalize_jsonpath_query and /dynamic/json/ endpoint docstrings expanded to clarify that $-prefixed selectors accept full jsonpath-ng expressions including filter expressions, with updated examples.
README Documentation
README.md
query parameter description extended to clarify accepted formats (JSONPath and dot-path from root) and explicitly note filter-expression support for selecting values via sibling fields.
Test Coverage
test_api.py
Added test_dynamic_json_filter_expression_by_name to verify filter expressions successfully return filtered values (HTTP 200), and test_dynamic_json_filter_expression_no_match_returns_422 to verify unmatched filters return HTTP 422.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A filter here, a filter there,
JSONPath hops through nested care,
No more hardcoded index schemes,
Just sibling fields and filter dreams!
With ext\.parse and tests so bright,
The rabbit's queries are now just right. 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add JSON query expressions' accurately describes the main change: expanding JSON query capabilities to support filter expressions, not just hardcoded indices.

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

✨ 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 and usage tips.

@github-actions github-actions Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 5, 2026
@deepsource-io

deepsource-io Bot commented May 5, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 8150117...83c0d74 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Secrets May 5, 2026 4:08a.m. Review ↗
Python May 5, 2026 4:08a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@penify-dev

penify-dev Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sourcery-ai sourcery-ai 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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gstraccini gstraccini Bot requested a review from guibranco May 5, 2026 05:03
@gstraccini gstraccini Bot added the 🚦 awaiting triage Items that are awaiting triage or categorization label May 5, 2026
@vercel

vercel Bot commented May 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
progressbar Ready Ready Preview, Comment May 5, 2026 5:46pm

@guibranco guibranco changed the title Add JSON query expressions Add JSON query expressions +semver: minor May 5, 2026
@guibranco

Copy link
Copy Markdown
Owner

@gstraccini review

@gstraccini

gstraccini Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Reviewing this pull request! 👀
Mergeable state: blocked

Commits included:
SHA: 83c0d7430b717c837e8a0eafa0e24992f9bd083d

@gstraccini

gstraccini Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

This pull request is ready ✅ for merge/squash.

@guibranco guibranco merged commit eb0798a into guibranco:main May 5, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚦 awaiting triage Items that are awaiting triage or categorization size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants