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

assertion failed: start.raw <= end.raw #303

Closed
2 tasks done
Cikmo opened this issue Apr 4, 2025 · 8 comments · Fixed by #311
Closed
2 tasks done

assertion failed: start.raw <= end.raw #303

Cikmo opened this issue Apr 4, 2025 · 8 comments · Fixed by #311
Assignees
Labels
bug Something isn't working

Comments

@Cikmo
Copy link

Cikmo commented Apr 4, 2025

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The language server crashes when entering an incomplete string at the end of the file.

Error message:

Encountered an unexpected error

This is a bug in Postgres Tools, not an error in your code, and we would appreciate it if you could report it along with the following information to help us fixing the issue:

Source Location: /home/runner/work/postgres-language-server/postgres-language-server/crates/pgt_text_size/src/range.rs:48:9
Thread Name: tokio-runtime-worker
Message: assertion failed: start.raw <= end.raw

It seems to be triggered by typing an unfinished string or identifier at the end of the file.

For example writing out:

CREATE TABLE "

will instantly cause this error, exiting the program.

To Reproduce

  1. Start the language server
  2. Begin typing a CREATE TABLE statement, and start a quoted identifier without closing it:
    CREATE TABLE "
    
  3. Crash should happen immediately

Expected behavior

There should be a linter warning/error notifying the user there is an invalid string, rather than the program panicking.

System information

Linux

@Cikmo Cikmo added the bug Something isn't working label Apr 4, 2025
@psteinroe
Copy link
Collaborator

hey @Cikmo, thanks for reporting!

would it be possible to provide the logs for this? I cannot reproduce this, neither in tests (#306) nor manually.

@psteinroe psteinroe self-assigned this Apr 4, 2025
@Cikmo
Copy link
Author

Cikmo commented Apr 4, 2025

Hey @psteinroe . So I checked the logs and did a bit more testing and it seems like it's not writing the unfinished string that causes it. It's if you file currently ends with a valid string, and you delete the identifier, it crashes.

└─┐pgt_lsp::handlers::text_document::did_change{uri="file:///path/supabase/schemas/private/file.sql", version=175, num_content_changes=1}
  └─┐pgt_workspace::workspace::server::change_file{path="/path/supabase/schemas/private/file.sql", version=175}
    ├─2025-04-04 10:27:17.357559801   0ms DEBUG pgt_workspace::workspace::server Modifying statement with id 15 (new id 16) in Some("/path/supabase/schemas/private/file.sql"). Range 12..12, Changed from '"create table"' to '"create table"', changed text: " "
    ├─2025-04-04 10:27:17.357669783   0ms INFO pgt_workspace::workspace::server::pg_query invalid statement, adding diagnostics.
  ┌─┘
  ├─2025-04-04 10:27:17.357873474   0ms INFO pgt_workspace::workspace::server Pulled 1 diagnostic(s)
┌─┘
└─┐pgt_lsp::handlers::completions::get_completions{url="file:///path/supabase/schemas/private/file.sql", character=13, line=32}
  └─┐pgt_workspace::workspace::server::get_completions{path="/path/supabase/schemas/private/file.sql", position="1285"}
  ┌─┘
┌─┘
└─┐pgt_lsp::handlers::text_document::did_change{uri="file:///path/supabase/schemas/private/file.sql", version=176, num_content_changes=1}
  └─┐pgt_workspace::workspace::server::change_file{path="/path/supabase/schemas/private/file.sql", version=176}
    ├─2025-04-04 10:27:17.358067003   0ms DEBUG pgt_workspace::workspace::server Deleting statement: id:0, path:"/path/supabase/schemas/private/file.sql"
    ├─2025-04-04 10:27:17.358096393   0ms DEBUG pgt_workspace::workspace::server Deleting statement: id:1, path:"/path/supabase/schemas/private/file.sql"
    ├─2025-04-04 10:27:17.358104299   0ms DEBUG pgt_workspace::workspace::server Deleting statement: id:3, path:"/path/supabase/schemas/private/file.sql"
    ├─2025-04-04 10:27:17.358112161   0ms DEBUG pgt_workspace::workspace::server Deleting statement: id:16, path:"/path/supabase/schemas/private/file.sql"
  ┌─┘
  ├─2025-04-04 10:27:17.358265513   0ms INFO pgt_workspace::workspace::server Pulled 16 diagnostic(s)
┌─┘
└─┐pgt_lsp::handlers::text_document::did_change{uri="file:///path/supabase/schemas/private/file.sql", version=177, num_content_changes=1}
  └─┐pgt_workspace::workspace::server::change_file{path="/path/supabase/schemas/private/file.sql", version=177}
    ├─2025-04-04 10:27:17.358365888   0ms ERROR pgt_cli::panic Encountered an unexpected error
    │ 
    │ This is a bug in Postgres Tools, not an error in your code, and we would appreciate it if you could report it along with the following information to help us fixing the issue:
    │ 
    │ Source Location: /home/runner/work/postgres-language-server/postgres-language-server/crates/pgt_text_size/src/range.rs:48:9
    │ Thread Name: tokio-runtime-worker
    │ Message: assertion failed: start.raw <= end.raw
    │ 
  ┌─┘
┌─┘
2025-04-04 10:27:17.358642863 INFO pgt_cli::commands::daemon Received shutdown signal
┘

@Cikmo
Copy link
Author

Cikmo commented Apr 4, 2025

And actually I'm not even sure it has anything to do with the string itself. Here you can see I just added and removed a space after it.

2025-04-04.123905.mp4

@psteinroe
Copy link
Collaborator

thanks for providing the details! if you are able to provide me the logfile from did_open to the crash I can repro it in tests easily. would that be possible?

@psteinroe
Copy link
Collaborator

ah @Cikmo, I just realised that we removed the actual content in the logs… will fix that in the next release. if possible, please upgrade once its released and then send the logs through. will ping you!

@Cikmo
Copy link
Author

Cikmo commented Apr 4, 2025

Alright

@psteinroe
Copy link
Collaborator

the new release is out :)

@Cikmo
Copy link
Author

Cikmo commented Apr 4, 2025

Here is the full server.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants