Affected area: Migrations
Supabase CLI version: current develop (d38ccd7)
Operating system: Any. Reproduced with a unit test on Linux.
Installation method: Built from source
Command
Actual output
When a migration statement fails, the CLI prints the statement and a caret under the position that PostgreSQL reports. If an earlier line of the statement contains multibyte characters, the caret is missing or printed under the wrong line.
For example, with this statement in a migration:
insert into notes (body) values ('éééééééé'),
(foo bar);
PostgreSQL reports the error position as a 1-based count of characters into the statement. markError compares that count with the UTF-8 byte length of each line, so the first line, which is longer in bytes than in characters, absorbs part of the offset. The output shows the statement without a caret, or with the caret under the wrong line.
Expected behavior
The caret appears under the character that PostgreSQL reports, on the correct line, regardless of the characters used on earlier lines.
Steps to reproduce
- Add a migration whose statement has a multibyte character on an early line and a syntax error on a later line, as shown above.
- Run
supabase db push against a database.
- Read the error output.
Additional context
The PostgreSQL protocol documentation states that the error position is measured in characters, not bytes. markError in apps/cli/src/command-internal/migration-apply.ts uses utf8ByteLength(line), and an existing unit test asserts the byte behavior. Measuring each line in code points fixes the offset. A unit test that calls markError with a multibyte first line fails on develop and passes with the change.
I have a fix with a unit test ready and can open a PR if this is open for contribution.
Affected area: Migrations
Supabase CLI version: current
develop(d38ccd7)Operating system: Any. Reproduced with a unit test on Linux.
Installation method: Built from source
Command
Actual output
When a migration statement fails, the CLI prints the statement and a caret under the position that PostgreSQL reports. If an earlier line of the statement contains multibyte characters, the caret is missing or printed under the wrong line.
For example, with this statement in a migration:
PostgreSQL reports the error position as a 1-based count of characters into the statement.
markErrorcompares that count with the UTF-8 byte length of each line, so the first line, which is longer in bytes than in characters, absorbs part of the offset. The output shows the statement without a caret, or with the caret under the wrong line.Expected behavior
The caret appears under the character that PostgreSQL reports, on the correct line, regardless of the characters used on earlier lines.
Steps to reproduce
supabase db pushagainst a database.Additional context
The PostgreSQL protocol documentation states that the error position is measured in characters, not bytes.
markErrorinapps/cli/src/command-internal/migration-apply.tsusesutf8ByteLength(line), and an existing unit test asserts the byte behavior. Measuring each line in code points fixes the offset. A unit test that callsmarkErrorwith a multibyte first line fails ondevelopand passes with the change.I have a fix with a unit test ready and can open a PR if this is open for contribution.