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

Invalidate alias with null character #282

Merged
merged 1 commit into from Mar 23, 2021
Merged

Invalidate alias with null character #282

merged 1 commit into from Mar 23, 2021

Conversation

kulla
Copy link
Member

@kulla kulla commented Mar 23, 2021

This PR includes a refinement for the alias string which does not allow the null character. This would remove all invalid cache entries with null characters in the alias and thus would force a refresh for them (see serlo/database-layer#80 and https://serlo.slack.com/archives/C0BMSC431/p1616161728010900 for examples). When the database layer returns such an invalid uuid an error would given by the API.

@@ -216,6 +216,23 @@ describe('uuid', () => {
})
})

test('returns an error when alias contains the null character', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Is it the right approach to return an error instead of null? This would mean:

  • CF: Entry would not end in the CF cache and the CF worker would use the legacy backend ✔️
  • Frontend: Would not display uuid and report this to sentry
  • API: Would report the error to sentry

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. This error should only occur if both the cache value and the therefore newly fetched value are both invalid.

@@ -40,10 +40,16 @@ export const InstanceDecoder: t.Type<Instance> = t.union([
t.literal(Instance.Ta),
])

const StringWithoutNullCharacter = t.refinement(
Copy link
Member Author

Choose a reason for hiding this comment

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

Here I use the deprecated t.refinement() instead of t.brand() due to gcanti/io-ts#576 since we would otherwise have a ts compiler error at https://github.com/serlo/api.serlo.org/blob/master/src/schema/uuid/video/resolvers.ts#L33

@inyono inyono merged commit 4500f5c into master Mar 23, 2021
@inyono inyono deleted the decoder-refinements branch March 23, 2021 13:36
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.

None yet

2 participants