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

fix: set default value for route schema to match type #5395

Closed
wants to merge 3 commits into from

Conversation

nflaig
Copy link
Contributor

@nflaig nflaig commented Apr 9, 2024

Alternative to #5394 which changes runtime behavior instead of updating type

Closes #5393

Checklist

@nflaig nflaig mentioned this pull request Apr 9, 2024
2 tasks
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Can you add a test for this change?

@mcollina
Copy link
Member

I personally prefer this to #5394.

@nflaig
Copy link
Contributor Author

nflaig commented Apr 23, 2024

Can you add a test for this change?

done

@nflaig nflaig closed this Apr 23, 2024
@nflaig nflaig reopened this Apr 23, 2024
@nflaig
Copy link
Contributor Author

nflaig commented Apr 23, 2024

I personally prefer this to #5394.

yeah, I like it more as well since updating the type might annoy some people, and it's really just an edge case inside hooks

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -206,7 +206,7 @@ Object.defineProperties(Request.prototype, {
get: () => context.config
},
schema: {
get: () => context.schema
get: () => context.schema ?? {}
Copy link
Member

@gurgunday gurgunday May 5, 2024

Choose a reason for hiding this comment

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

Isn't this enough to not get undefined?

Nope it's the deprecated version, sorry!

Copy link
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

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

lgtm

I think in next we should fix the type instead and it should be undefined

Comment on lines +90 to +91
t.not(req.routeSchema, undefined)
t.not(req.routeOptions.schema, undefined)
Copy link
Member

Choose a reason for hiding this comment

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

TBH I don't like this default.

How do the user know if a schema has been set?

Now: if(req.routeSchema==null)

Then: if(req.routeSchema.id==null) + the overhead to create a new empty object

Why don't we fix the types instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reopened #5394, both PRs fix the issue I reported but you guys know best what other use cases to consider.

I go with whatever is decided here :)

Copy link
Member

Choose a reason for hiding this comment

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

If we go with this in v4, I’d say right after we should revert this in v5 and merge your other (type) PR there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we go with this in v4, I’d say right after we should revert this in v5 and merge your other (type) PR there

sounds like a plan, do you want the revert of this to be part of the type PR then? (needs rebase on next first)

Copy link
Member

Choose a reason for hiding this comment

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

@gurgunday @Eomm then we go with the other PR. Let's not land and revert.

@nflaig
Copy link
Contributor Author

nflaig commented May 7, 2024

Closing as #5394 has been merged to main

@nflaig nflaig closed this May 7, 2024
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.

Route schema might be undefined
5 participants