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

🐛 Unable to create auth token #153

Open
1 task done
jenky opened this issue Dec 28, 2023 · 2 comments
Open
1 task done

🐛 Unable to create auth token #153

jenky opened this issue Dec 28, 2023 · 2 comments
Assignees
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@jenky
Copy link

jenky commented Dec 28, 2023

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

Database

PostgreSQL

What happened?

Original issue spiral/cycle-bridge#85

SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type bytea
CONTEXT:  unnamed portal parameter $5 = '...'

The payload contains an url. Upon json_encode, it will add backslashes to escape the uri e.g http:\/\/127.0.0.1:8080\/ which I guess somewhat invalid for bytea column. Removing the URL from the payload resolves the issue.

Version

Postgres 16.1
PHP 8.3
@jenky jenky added status:to be verified Needs to be reproduced and validated. type:bug Bug labels Dec 28, 2023
@roxblnfk roxblnfk added this to Cycle Dec 29, 2023
@roxblnfk roxblnfk moved this to Todo in Cycle Dec 29, 2023
@iGrog
Copy link

iGrog commented Jan 22, 2024

In PostgreSQL, the BYTEA data type is designed to store binary data, such as images, sounds, and other raw byte sequences. The BYTEA type is intended for representing data in binary form, and inserting strings with backslashes may cause issues due to the intricacies of byte handling and escaping in SQL.

If you attempt to insert a string with backslashes directly into a BYTEA column, it can lead to confusion, as the backslash () in SQL is used for escaping special characters. Therefore, when inserting a string with backslashes, they should be properly escaped.

Example of a problematic string:

INSERT INTO your_table (binary_column) VALUES ('some data with a slash \');

In this case, PostgreSQL might interpret the backslash as the beginning of an escaped sequence, leading to an error or misinterpretation of the data.

To avoid such situations, you can use the E'...' function, which allows the use of escape sequences in strings:

INSERT INTO your_table (binary_column) VALUES (E'some data with a slash \\');

In this example, E'...' enables the use of an escaped backslash in the string. Note that each backslash must be doubled to prevent interpretation errors.

Or check this function https://www.php.net/manual/en/function.pg-escape-bytea.php

@jenky
Copy link
Author

jenky commented Jan 23, 2024

Thank you. However, if you refer to the original issue, I do not have control over how the data is being serialized.

https://github.com/spiral/cycle-bridge/blob/e0bda2ca40c696ecd82de3d49fb32b40307bc63b/src/Auth/Token.php#L50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
Status: Todo
Development

No branches or pull requests

4 participants