Skip to content

"bump overlay" should log a warning when JSONPath doesn't match anything #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hkosova opened this issue Nov 8, 2024 · 5 comments · Fixed by #673
Open

"bump overlay" should log a warning when JSONPath doesn't match anything #588

hkosova opened this issue Nov 8, 2024 · 5 comments · Fixed by #673
Labels

Comments

@hkosova
Copy link

hkosova commented Nov 8, 2024

When writing JSONPath expressions, it's common to make mistakes where the expression is syntactically valid but matches nothing. Currently bump overlay just silently ignores such targets, which complicates troubleshooting.

It would be nice if the tool could warn the user about such noop targets. These warnings could be either always on, or enabled by some flag. For example speakeasy overlay apply has the --strict flag for this purpose.


Some common errors:

  1. Typos in node names, values, filters:

    $..parameters[?( @.name == 'fron_date' )]
    
    $..paramaters[?( @.name == 'from_date' )]
    
    $.servers[?( @.desciption == 'Dev' )]
    
  2. Skipping nodes in a path:

    - target: $.components.schemas.SchemaName.propName   # should be: ...SchemaName.properties.propName
      update:
        description: something
        example: 123
  3. Extra nodes in a path:

    $.paths.*[?( @.operationId == 'get_foo' )].get   # '.get' is not needed here
  4. Consider an overlay that targets an endpoint by its path or operationId:

    $.paths['/foos/{id}'].get
    
    $.paths.*[?( @.operationId == 'get_foo' )]

    Later this endpoint gets renamed (e.g. /foos/{id} becomes /foos/{foo_id}) or its operationId gets changed (e.g. maybe op IDs are autogenerated and the algorithm changes).


As an overlay author and maintainer, I would like to get notified about non-matches so that I can update the overlay to match the current state of my API.

@samanthawritescode
Copy link

Big +1 to this. I'm starting to write and maintain overlays for my spec and I'm worried about updates to my API unknowingly affecting how my overlays work. I would like to know so I can update the overlays.

@grossyoan
Copy link

grossyoan commented Feb 27, 2025

Thanks for your feedback, it fully makes sense.

We're talking about it internally to see how it could be added to our roadmap.

@grossyoan
Copy link

Hi,

This feature is now available in the last version of the CLI. Thanks again for your feedback 🙏

Have a great day,
Yoan

@samanthawritescode
Copy link

@grossyoan thank you for adding this! Would it be possible to force the bump overlay command to fail with a non-zero exit code if one of the "no matching elements" warnings exists? Perhaps with a --strict flag?

I don't have faith that all engineers at my company will heed the warnings without an explicitly failing command 😅

@grossyoan
Copy link

Hi @samanthawritescode,

Thanks for your feedback.

We don't usually fail an action unless there's something "fatal" to it, we prefer to output warnings, like we do during deployment.

However, I totally get your use case. We'll talk about it internally to see if we offer a --strict option in the future.

Have a nice day,
Yoan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants