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

psl: fix newline boundary search in relation reformatting #3457

Merged
merged 1 commit into from Dec 1, 2022

Conversation

tomhoule
Copy link
Contributor

When adding an @relation attribute to a forward relation field in the relation reformatting code that deals with adding missing relation fields and attributes, we searched for the last character before a newline to check whether it is a carriage return, but we failed to check whether the byte offset was a char boundary first. This caused crashes.

closes prisma/prisma#14895

@tomhoule tomhoule requested a review from a team as a code owner November 30, 2022 12:31
@tomhoule tomhoule added this to the 4.8.0 milestone Nov 30, 2022

model somemodel {
frownyFaceId String
frownyFace frownyface // 囧 @relation(fields: [], references: [])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is very wrong

Copy link
Contributor

@jkomyno jkomyno left a comment

Choose a reason for hiding this comment

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

It seems this bug is now fixed! Thanks Tom

@tomhoule
Copy link
Contributor Author

tomhoule commented Dec 1, 2022

This is still broken, we have to address #3457 (comment)

@tomhoule tomhoule force-pushed the psl-reformatter-char-boundaries branch from cb87bb6 to 734e168 Compare December 1, 2022 08:10
When adding an @relation attribute to a forward relation field in the
relation reformatting code that deals with adding missing relation
fields and attributes, we searched for the last character before a
newline to check whether it is a carriage return, but we failed to
check whether the byte offset was a char boundary first. This caused
crashes.

closes prisma/prisma#14895
@tomhoule tomhoule force-pushed the psl-reformatter-char-boundaries branch from 734e168 to a3e1d2f Compare December 1, 2022 08:21
@tomhoule tomhoule merged commit 7f090a3 into main Dec 1, 2022
@tomhoule tomhoule deleted the psl-reformatter-char-boundaries branch December 1, 2022 08:57
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.

UTF-8 Error: index is not a char boundary
2 participants