FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: resolve 15 bugs across CLI and plugins by praneshnikhar · Pull Request #23162 · cloudquery/cloudquery · GitHub

fix: resolve 15 bugs across CLI and plugins - #23162

Open
praneshnikhar wants to merge 2 commits into
cloudquery:mainfrom
praneshnikhar:fix/bug-fixes
Open

fix: resolve 15 bugs across CLI and plugins#23162
praneshnikhar wants to merge 2 commits into
cloudquery:mainfrom
praneshnikhar:fix/bug-fixes

Conversation

Copy link
Copy Markdown

CLI bugs:

  • Nil pointer dereference (cli/internal/publish/plugins.go): req.Header.Add calls placed before the err != nil check from http.NewRequestWithContext — if URL parsing fails or context is cancelled, this panics instead of returning an error.
  • Goroutine leaks (cli/internal/transformerpipeline/pipeline.go): Two unbuffered channel patterns where spawned goroutines block forever after the pipeline closes — the Recv goroutine in startBlocking and the Send goroutine in Send. Fixed by making channels buffered (size 1) and adding isClosed checks.
  • Zero metrics sent to analytics (cli/cmd/sync_v3.go): The mt metrics.Metrics variable was declared but never populated — all sync metric payloads were sent as zeros. Now built from statsPerTable data.
  • Wrong transformer option (cli/cmd/sync_v2.go:34): WithRemovePKs() called twice instead of WithRemovePKs() + WithRemoveUniqueConstraints() in the v2→v3 append-mode path — unique constraints were silently preserved when they should be removed.
  • Data races (cli/internal/analytics/client.go): Global client and cachedSyncEventDetails variables accessed from multiple goroutines without synchronization. Added sync.RWMutex protection.
  • Dead code (cli/internal/publish/plugins.go): Redundant second os.ReadFile that can never trigger (the file was already confirmed to exist by the first read).

Plugin bugs:

  • SQL injection (ClickHouse queries/table.go, PostgreSQL migrate.go, DuckDB+SQLite migrate.go): Table/database names and TTL strings interpolated directly into SQL queries — now sanitized with util.SanitizeID, pgx.Identifier, or parameterized queries.
  • Nil dereference (ClickHouse client/table.go): *uint8 result dereferenced without nil check in equalTTLs. Also used context.Background() instead of the caller's context.
  • panic in production (MongoDB write.go): panic(err) used instead of error returns when JSON unmarshal fails in transformArr. Replaced with proper error propagation through the call chain.
  • Nil tx rollback (PostgreSQL migrate.go): Deferred tx.Rollback(ctx) on nil transaction when BeginTx fails mid-function (CockroachDB path). Added nil guard.
  • Resource leak (GCS write.go): *storage.Writer not closed on WriteHeader/WriteContent/WriteFooter errors, and w.Close() on nil writer when message channel is empty.

CLI core fixes:
- Move err check before req.Header.Add in plugins.go (nil pointer)
- Fix goroutine leaks in transformerpipeline pipeline.go
- Populate mt metrics in sync_v3.go (was always sending zeros)
- Fix duplicate WithRemovePKs() -> WithRemoveUniqueConstraints() in sync_v2.go
- Add mutex protection for data races in analytics/client.go
- Remove dead code in plugins.go GetSpecJsonScheme

Plugin fixes:
- Sanitize SQL in clickhouse table queries (SQL injection)
- Fix nil dereference + context.Background in clickhouse equalTTLs
- Replace panic(err) with error returns in mongodb write.go
- Add tx nil guard in postgresql migrate.go deferred rollback
- Sanitize table names in postgresql dropTable/addColumn
- Fix SQL injection in duckdb/sqlite pragma_table_info
- Fix resource leak in gcs write.go (w.Close on all error paths)

erezrokah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hi @praneshnikhar, thank you for your contribution. Can you please open a bug report with a reproduction per issue fixed in this PR? This will help us understand the impact per issue and prioritize the review accordingly

Copy link
Copy Markdown
Author

suree! @erezrokah

Copy link
Copy Markdown
Author

Hi @praneshnikhar, thank you for your contribution. Can you please open a bug report with a reproduction per issue fixed in this PR? This will help us understand the impact per issue and prioritize the review accordingly

Done — opened issues #23164 through #23173, each with reproduction steps. Let me know if you need anything else!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL