Skip to content

SQL autocomplete is unexpectedly applied when pressing Enter after ; #1751

Description

@steffenbusch

lnav version
v0.14.1

Describe the bug
When entering an SQL query in lnav, an autocomplete suggestion can appear after the terminating ;. The suggested text appears to come from one of the HTTP header values contained in the Caddy access log.

This does not happen the first time the query is entered and executed. On the first run, no autocomplete suggestion is shown for the final ; and the query executes normally.

When entering the same query again, an autocomplete suggestion appears after the final ;.

Pressing Enter then accepts the suggestion instead of executing the SQL query.

This unexpectedly modifies the query and can result in an SQL syntax error.

To Reproduce
Steps to reproduce the behavior:

  1. Open lnav with the attached Caddy access log and enter SQL mode.

  2. Enter the following query for the first time:

select * from caddy_log where 1=1;
  1. No autocomplete suggestion is shown for the final ;. Press Enter and the query executes normally.

  2. Enter the same query again:

select * from caddy_log where 1=1;
  1. After typing the final ;, an autocomplete suggestion appears.

In this case, the suggested text appears to come from the Alt-Svc response header in the Caddy log, for example:

h3=":443"; ma=2592000
Image
  1. Press Enter.

  2. The autocomplete suggestion is inserted into the query instead of executing it. The resulting modified query fails with an SQL syntax error.

Image

Example Caddy access log entries

{"level":"info","ts":1789375804.3620076,"logger":"http.log.access.example","msg":"handled request","request":{"remote_ip":"192.0.2.10","remote_port":"44050","client_ip":"192.0.2.10","proto":"HTTP/1.1","method":"GET","host":"example.com","uri":"/firebase-key.json","headers":{"Next-Action":["x"],"X-Nextjs-Request-Id":["deadbeef"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept-Encoding":["gzip, deflate"],"Accept":["*/*"],"Connection":["keep-alive"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"http/1.1","server_name":"example.com","ech":false}},"bytes_read":0,"user_id":"","duration":0.000580557,"size":664,"status":200,"resp_headers":{"Server":["Caddy"],"Alt-Svc":["h3=\":443\"; ma=2592000"],"Content-Type":["text/html"]},"stbu_server_name":"example.com"}
{"level":"info","ts":1789375805.1945455,"logger":"http.log.access.example","msg":"handled request","request":{"remote_ip":"192.0.2.10","remote_port":"43534","client_ip":"192.0.2.10","proto":"HTTP/1.1","method":"GET","host":"example.com","uri":"/","headers":{"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"],"Accept-Encoding":["gzip, deflate"],"Accept":["application/json"],"Connection":["keep-alive"],"X-Livewire":["1"],"Content-Type":["application/json"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"http/1.1","server_name":"example.com","ech":false}},"bytes_read":0,"user_id":"","duration":0.000663673,"size":664,"status":200,"resp_headers":{"Server":["Caddy"],"Alt-Svc":["h3=\":443\"; ma=2592000"],"Content-Type":["text/html"]},"stbu_server_name":"example.com"}

Expected behavior

Pressing Enter after a complete SQL statement ending in ; should execute the query, not accept an autocomplete suggestion.

The behavior should also be consistent between the first and subsequent executions of the same query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions