Skip to content

fix(account): handle empty $in array to prevent PostgreSQL IN () syntax error#10554

Merged
ArtyomSavchenko merged 2 commits intohcengineering:developfrom
spatialy:fix/empty-in-clause-postgres-10553
Feb 25, 2026
Merged

fix(account): handle empty $in array to prevent PostgreSQL IN () syntax error#10554
ArtyomSavchenko merged 2 commits intohcengineering:developfrom
spatialy:fix/empty-in-clause-postgres-10553

Conversation

@spatialy
Copy link
Contributor

Summary

  • In buildWhereClause (postgres.ts), emit FALSE when a $in array is empty instead of generating invalid IN () SQL that PostgreSQL rejects with a syntax error.
  • In getWorkspacesInfoWithStatusByIds (utils.ts), add an early return [] when uuids is empty so callers (GitHub, Gmail, Backup services) never reach the query with an empty list.

Fixes #10553

Test plan

  • Self-host on PostgreSQL with the GitHub integration configured but no repos connected — confirm the IN () error no longer appears in account logs every ~6 minutes.
  • Verify getWorkspacesInfo returns [] when called with an empty id array instead of throwing a PostgreSQL syntax error.
  • Verify existing workspace-lookup behaviour is unchanged when a non-empty id array is provided.

…SQL syntax error

buildWhereClause now emits FALSE for empty $in arrays instead of invalid
IN () syntax. Also adds an early return in getWorkspacesInfoWithStatusByIds
so callers like the GitHub/Gmail/Backup services never hit the query with
an empty uuid list.

Fixes hcengineering#10553

Signed-off-by: Yulian Diaz <5605867+spatialy@users.noreply.github.com>
@huly-github-staging
Copy link

Connected to Huly®: UBERF-15673

@spatialy
Copy link
Contributor Author

@ArtyomSavchenko, this is preventing GitHub sync from working properly in the latest version deployed with Postgres. Can you check?

…WithStatusByIds

Per review feedback from @ArtyomSavchenko: use Array.isArray() in addition to
the length check to handle runtime cases where uuids may not be an array.

Signed-off-by: Yulian Diaz <5605867+spatialy@users.noreply.github.com>
@ArtyomSavchenko ArtyomSavchenko merged commit 66deebd into hcengineering:develop Feb 25, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: getWorkspacesInfo generates invalid SQL IN () when called with empty array (PostgreSQL)

3 participants