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

influxdb3 show databases incorrect json when no databases #26057

Closed
jules-ch opened this issue Feb 22, 2025 · 0 comments · Fixed by #26130
Closed

influxdb3 show databases incorrect json when no databases #26057

jules-ch opened this issue Feb 22, 2025 · 0 comments · Fixed by #26130
Labels

Comments

@jules-ch
Copy link

jules-ch commented Feb 22, 2025

Steps to reproduce:
List the minimal actions needed to reproduce the behaviour.

  1. Call influxdb3 show databases --format json without any databases

Expected behaviour:
Return valid empty array json []

Actual behaviour:
Return only closing bracket ]

@hiltontj hiltontj added the v3 label Feb 25, 2025
mgattozzi added a commit that referenced this issue Mar 12, 2025
This fixes an issue when querying for data with no values would create
incomplete JSON. This first showed up in #26057 due to
`influxdb3 show database` having no data on a fresh run of the server.

While the code we had, handled the fact that if there was no data
written then we should have written `[]`, however, there was a subtle
edge case we did not handle. If we got a record batch and wrote it into
the writer we would expect it to then write the opening `[` even if
there was no data. However, this was not the case. It would only do so
once it was actually writing data or we called `finish` which doesn't
work for us here since we're hacking around the API in order to stream
data back.

This took quite a while to track down, but the end result is a simple
fix to a hard problem: if we're polling data for the first time and the
first record batch is empty just write a `[` into the Body of the
request. Our later code will handle closing the bracket and we're all
good. If there is data then the JSON writer can handle it as normal.

Closes #26057
mgattozzi added a commit that referenced this issue Mar 12, 2025
This fixes an issue when querying for data with no values would create
incomplete JSON. This first showed up in #26057 due to
`influxdb3 show database` having no data on a fresh run of the server.

While the code we had, handled the fact that if there was no data
written then we should have written `[]`, however, there was a subtle
edge case we did not handle. If we got a record batch and wrote it into
the writer we would expect it to then write the opening `[` even if
there was no data. However, this was not the case. It would only do so
once it was actually writing data or we called `finish` which doesn't
work for us here since we're hacking around the API in order to stream
data back.

This took quite a while to track down, but the end result is a simple
fix to a hard problem: if we're polling data for the first time and the
first record batch is empty just write a `[` into the Body of the
request. Our later code will handle closing the bracket and we're all
good. If there is data then the JSON writer can handle it as normal.

Closes #26057
mgattozzi added a commit that referenced this issue Mar 12, 2025
This fixes an issue when querying for data with no values would create
incomplete JSON. This first showed up in #26057 due to
`influxdb3 show database` having no data on a fresh run of the server.

While the code we had, handled the fact that if there was no data
written then we should have written `[]`, however, there was a subtle
edge case we did not handle. If we got a record batch and wrote it into
the writer we would expect it to then write the opening `[` even if
there was no data. However, this was not the case. It would only do so
once it was actually writing data or we called `finish` which doesn't
work for us here since we're hacking around the API in order to stream
data back.

This took quite a while to track down, but the end result is a simple
fix to a hard problem: if we're polling data for the first time and the
first record batch is empty just write a `[` into the Body of the
request. Our later code will handle closing the bracket and we're all
good. If there is data then the JSON writer can handle it as normal.

Closes #26057
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants