Commit Graph

95 Commits

Author SHA1 Message Date
Nathan Wallace
0d6cb1afad Fix #4713: Add nil check in initialiseSchemaAndTableSuggestions (#4879)
* Add test for #4713: initialiseSchemaAndTableSuggestions should handle nil client

* Fix #4713: Add nil check in initialiseSchemaAndTableSuggestions
2025-11-15 11:17:46 -05:00
Nathan Wallace
b1e9500c1b Fix #4812: Add size limits to autocomplete suggestions maps (rebased) (#4888)
* Add test for #4812: Autocomplete suggestions should have size limits

This test verifies that autocomplete suggestion maps enforce size limits
to prevent unbounded memory growth. The test calls setTablesForSchema()
and setQueriesForMod() methods that should enforce:
- Maximum 100 schemas in tablesBySchema
- Maximum 500 tables per schema
- Maximum 100 mods in queriesByMod
- Maximum 500 queries per mod

This test will fail until the size limiting implementation is added.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4812: Add size limits to autocomplete suggestions maps

Implements bounded size for autocomplete suggestion maps to prevent
unbounded memory growth with large schemas:

- Added constants for max schemas (100) and max tables per schema (500)
- Created setTablesForSchema() and setQueriesForMod() methods that enforce
  limits using LRU-style eviction when limits are exceeded
- Updated interactive_client_autocomplete.go to use the new bounded setter

This prevents excessive memory consumption when dealing with databases
that have hundreds of connections with many tables each.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 11:10:22 -05:00
Nathan Wallace
f799be5447 Handle single word and empty string in lastWord() closes #4787 (#4891)
* Add test for #4787: lastWord() panics on single word or empty string

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4787: Handle single word and empty string in lastWord()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 11:10:06 -05:00
Nathan Wallace
22bfc9991f initialisationComplete flag synchronized closes #4803 (rebased) (#4886)
* Add test for #4803: Race condition in initialisationComplete flag

Add TestInitialisationComplete_RaceCondition to demonstrate the data race
that occurs when the initialisationComplete boolean flag is accessed
concurrently by multiple goroutines without synchronization.

The test simulates:
- Init goroutine writing to the flag
- Query executor reading via isInitialised()
- Notification handler reading the flag directly

This test will fail when run with the -race flag, exposing the bug.

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4803: Use atomic.Bool for initialisationComplete flag

Replace the plain boolean initialisationComplete field with atomic.Bool
to prevent data races when accessed concurrently by multiple goroutines.

Changes:
- Change field type from bool to atomic.Bool
- Use .Store(true) for writes
- Use .Load() for reads in isInitialised() and handleConnectionUpdateNotification()
- Update test to use atomic operations

The test now passes with -race flag, confirming the race condition is fixed.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 10:48:46 -05:00
Nathan Wallace
cb1fa48173 Fix flaky TestQueryContextLeakage test (#4887)
Changes:
1. Renamed TestQueryContextLeakage -> TestContextCancellationTiming
   - The test was checking cancellation timing, not memory leaks
   - Updated comments to reflect actual purpose

2. Increased timeout from 1ms to 100ms
   - 1ms is too aggressive for CI runners under load
   - 100ms still catches real deadlocks while avoiding flakiness
   - Added detailed comments explaining the timeout choice

3. Added TestNoGoroutineLeaks using goleak
   - Properly tests for actual resource leaks (goroutines)
   - More reliable than memory-based leak detection
   - Uses industry-standard goleak library

The original 1ms timeout caused intermittent CI failures on slower
runners, as context cancellation involves goroutine scheduling that
has no guaranteed sub-millisecond timing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 08:05:00 -05:00
Nathan Wallace
2e5f3fda97 Add comprehensive passing tests from bug hunting initiative (#4864) 2025-11-13 09:26:46 +08:00
Nathan Wallace
5e1d316759 Fix #4710: Return empty slice instead of nil in getTableAndConnectionSuggestions (#4734) 2025-11-11 19:25:03 +08:00
Nathan Wallace
7996d3c878 Fix #4712: Make Result.Close() idempotent (#4741) 2025-11-11 18:53:18 +08:00
Puskar Basu
e19d35c457 chore: update module to v2 and bump Go version to 1.24 (#4597) 2025-07-07 16:03:56 +05:30
Puskar Basu
1c9f3ac9fc Merge branch 'v2.0.x' into develop 2025-07-07 13:06:15 +05:30
Puskar Basu
ae106141a7 Fix 'unused' linting errors 2025-06-17 12:20:12 +05:30
Puskar Basu
da2f3ecc03 Upgrade to pipe-fittings v2, go-kit v1 (#4485) 2025-03-06 16:34:18 +05:30
kai
112647bae0 tidy 2024-10-15 11:44:13 +01:00
Puskar Basu
ad1259f888 update and enable config precedence tests 2024-10-15 15:18:09 +05:30
kai
dde7c23ed5 rename Connection to SteampipeConnection
remove unneeded code
use CloudMetadata from pipe-fittings
2024-09-27 18:14:28 +05:30
kai
1804741bbd tidy 2024-09-27 18:14:28 +05:30
kai
6efd1fd6b2 query display and query result moved to pipe fittings 2024-09-27 18:14:28 +05:30
kai
5fd5ae0740 timing broken 2024-09-27 18:14:28 +05:30
kai
e5b1927a63 tidy imports 2024-09-27 18:14:28 +05:30
kai
cb681c67cc compiles but needs testing 2024-09-27 18:14:28 +05:30
kai
ef21f1452e steampipe compiles 2024-09-27 18:14:28 +05:30
kai
cd07bf20f1 working on it 2024-09-27 18:13:12 +05:30
kaidaguerre
07782a2b13 Adds support for verbose timing information. Closes #4237. Closes #4244
- JSON output format has changed to move the rows to under a `rows` property, with timing information under the `metadata` property
- Update timing display to show rows returned and rows fetched, as well as adding verbose mode which lists all scans
- Use enums for output mode and timing mode - timing is now either `on`, `off` or `verbose`
- Bugfix: ensure error is returned from ExecuteSystemClientCall. Closes #4246
2024-04-17 10:12:17 +01:00
kaidaguerre
e6e9714e4c Update all ErrorAndWarnings function returns to pass by value, removing possibility of nil ErrorAndWarnings. Closes #3974 (#4212) 2024-03-21 11:46:10 +00:00
Binaek Sarkar
bd9fce7153 Fixes issue where using any meta command would load connection state even if not required. Closes #3614 2024-01-08 10:18:15 +00:00
kaidaguerre
62af6d325a Prevent operators <>, > < in steampipe_plugin_column table being html encoded. Closes #4013 2023-12-05 19:40:53 +00:00
kaidaguerre
0199aaceca Add function to clear connection cache. Closes #3937
* Add function to clear connection cache.
* Update FDW to v1.9.0 - Add ability to clear connection cache by inserting into settings table.
* Update plugin sdk to v5.6.1
* fix listen unit tests

(cherry picked from commit 4fa11a424e)
2023-09-29 20:20:08 +01:00
kai
5812c59f10 add introspection tables to autocomplete. Closes #3920
gracefully handle startup failure to read ResolvedListenAddresses in server state
2023-09-27 19:45:36 +01:00
kaidaguerre
79606c5bcd Rename internal introspection tables. Fix warning notifications from RefreshConnections. Improve error handlingh for config inconsistencies in conneciton and plugin config. Closes #3886 2023-09-22 16:02:41 +01:00
kaidaguerre
7feb305fde Provide mechanism for plugin manager to send warnings back to CLI. Closes #3603 (#3835) 2023-09-13 15:34:15 +01:00
Binaek Sarkar
a3a714d6cd Fixes issue where temporary tables are dropped in interactive prompt when pool connections are recycled. Closes #3359. Closes #3781 2023-09-06 16:46:40 +01:00
kaidaguerre
2a86d08445 Add support to retrieve plugin rate limiter definitions and use to populate steampipe_rate_limiter table. Closes #3805 (#3803) 2023-09-06 13:28:22 +01:00
Binaek Sarkar
edfe58f815 Revert "Fixes issue where temporary tables are lost in the middle of a long running interactive session. Closes #3543" (#3789)
This reverts commit 047d8b5556.
2023-09-01 14:33:05 +01:00
Binaek Sarkar
047d8b5556 Fixes issue where temporary tables are lost in the middle of a long running interactive session. Closes #3543 2023-08-29 12:18:20 +01:00
Binaek Sarkar
132b3a7c32 Fixes issue where metaquery hangs in interactive prompt. Closes #3775 2023-08-28 17:21:30 +01:00
Binaek Sarkar
08b447a261 Differentiate between user and system queries using application name. Closes #3600 2023-08-25 16:50:27 +01:00
Puskar Basu
6aaf9bc5be Update 'sperr' import references. Closes #3748 2023-08-17 13:52:04 +05:30
kaidaguerre
202cb68692 Add HCL support for defining rate limiters, with filewatching as per connection config. Closes #3746 2023-08-11 14:24:44 +01:00
Binaek Sarkar
72323ef37a Merge branch 'v0.20.x' 2023-08-09 17:48:09 +05:30
Puskar Basu
5995e35937 Fix issue where interactive prompt exits/crashes when the code panics. Closes #3713 2023-08-07 11:23:31 +01:00
Binaek Sarkar
854819f8f1 Validates workspace profile cache settings. Closes #3646 2023-07-14 13:22:08 +01:00
Binaek Sarkar
d807c9c093 Fixes issue where CAPITAL arguments to '.cache' meta command were not getting recognised. Closes #3670 2023-07-13 15:37:48 +01:00
kaidaguerre
b06348757a Fix linting warnings
---------

Co-authored-by: Binaek Sarkar <binaek@turbot.com>
Co-authored-by: Puskar Basu <puskar@turbot.com>
2023-07-06 16:08:23 +01:00
Binaek Sarkar
120999a374 Adds feature where type '.cache' in interactive shows the current value of cache. Closes #2439 2023-07-04 16:02:52 +01:00
Binaek Sarkar
aeec7622d8 Fixes issue where interactive prompt autocomplete dropdown was showing connections in error. Closes #3628 2023-06-30 08:53:22 +01:00
Binaek Sarkar
bb53c87c86 Fixes issue where connection state fails to load when connecting to pre-0.20.7 service. Closes #3612 2023-06-22 16:21:10 +01:00
Binaek Sarkar
c3d21d4436 Fixes issue where 'dot' commands in interactive prompt fail to execute if there's a file/folder by the same name in the working directory. Closes #3558 2023-06-12 16:35:43 +01:00
kai
7753d5385d If custom is search path is set, only fail a query if ALL connections are in error 2023-05-18 16:54:56 +01:00
kai
8ec8c76907 Fix .connection meta-command in interactive returning an empty table #3449 2023-05-18 14:56:24 +01:00
kai
3b1e99182a Replace all '...' with ellipsis … in terminal output. Closes #3441 2023-05-18 10:41:27 +01:00