Skip to content
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

Upgrade query-string to v8.1.0 #1789

Closed
wants to merge 1 commit into from

Conversation

anshgoyalevil
Copy link
Member

@anshgoyalevil anshgoyalevil commented Sep 15, 2023

Which problem is this PR solving?

Description of the changes

How was this change tested?

  • locally

Checklist

Signed-off-by: Ansh Goyal <[email protected]>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

These changes seem problematic to me. Just because some library returns a different result, you changes a lot of signatures in our code, expanding them to more states. Why do those states make sense on all those places? It reduces strong typing.

I would rather add a util function that wraps the library but returns the same [] signature as before. It doesn't make sense se introducing null everywhere.

@anshgoyalevil
Copy link
Member Author

Totally agree. I didn't think of the wrapper function approach at first. Thanks for that. Making the changes.

However, doesn't the current approach seem more readable as the query-string's function signature matches with what we are expecting our function's parameters to be?

@yurishkuro
Copy link
Member

there is a principle "be liberal in what you accept and conservative in what you send". Loosening the type of fields within structs breaks that principle because other places in the code that read the struct now must deal with bigger surface.

On the other hand, loosening the type of function parameters seems to align with this principle, but it's not good either, especially in the existing code base. By loosening function signature when it was already tight and the existing code was already confirming to stricter type you are giving permission to that other code to be more sloppy about the typing.

Implementation-wise, I don't have a strong opinion, it could be a helper function, or just x ?? [] when the library is called.

@anshgoyalevil
Copy link
Member Author

there is a principle "be liberal in what you accept and conservative in what you send". Loosening the type of fields within structs breaks that principle because other places in the code that read the struct now must deal with bigger surface.

On the other hand, loosening the type of function parameters seems to align with this principle, but it's not good either, especially in the existing code base. By loosening function signature when it was already tight and the existing code was already confirming to stricter type you are giving permission to that other code to be more sloppy about the typing.

Implementation-wise, I don't have a strong opinion, it could be a helper function, or just x ?? [] when the library is called.

Learning more daily 🚀 Thanks for the useful info.
Have tried this wrapper approach to modify the function's typecasting for the first time.

@anshgoyalevil
Copy link
Member Author

Superseded by #1794

yurishkuro pushed a commit that referenced this pull request Sep 16, 2023
….parse() (#1794)

## Which problem is this PR solving?
- This PR upgrades the query-string dep from v6.3.0 to v8.1.0
- improved version of:
#1789
- part of: #998

## Description of the changes
- In query-string v6.4.0, null type was introduced.
sindresorhus/query-string@49d2203#diff-7aa4473ede4abd9ec099e87fec67fd57afafaf39e05d493ab4533acc38547eb8R36
- Further, in later versions, string[] type is changed to (string |
null)[]
- This PR adds a wrapper function for `queryString.parse()` function to
modify its type as per our codebase.

## How was this change tested?
- locally

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Ansh Goyal <[email protected]>
@anshgoyalevil anshgoyalevil deleted the upgrade-rrd branch September 18, 2023 13:35
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.

2 participants