strata-cli 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55ce87ef5e374c4b0a1c60a5e23081596108a353bc543272a7aa2b749fd56930
4
- data.tar.gz: 27bc1dab19e8dbc6efb1256b25c36389a182157dad90bd9fdfd14f9c73f648af
3
+ metadata.gz: 0d03609109e6f552c2e875606d903cda5f93dabf6208d83c8c86d68172a1bc00
4
+ data.tar.gz: 679ac8a2e506acd83cbbb2cf40b71cd923fe3fd522b607d9155f326b792a5a9a
5
5
  SHA512:
6
- metadata.gz: 9e9824b911b205b5876c1c104cfa2c187c7d768197b87ffda5bf3d891bfd2abc9140309b422c173fe8d964a9fa4939aa331bdc6e8412e25b0e6a37d172e4453e
7
- data.tar.gz: 0bc343e01fac99afacc7bb5e3c188d530c7b7ceafa359c0c269d38c32e536b837bca2038b95ad2962672c5ebcc961eb7a972f72fee91abc5a3707c22ebf64a49
6
+ metadata.gz: c80b2f7643772c5e5782525521c2f63e09f3ff68b56c76a00dd862fd272d8636ce00baadea9b134a70da37f1b87a3a38aceafa6142d7334baa9b59e7dc5a9cba
7
+ data.tar.gz: 6ddcae6b6515c91e32a244307a9383a738d0b67eb4aad4581508f797f96c20fdd2ca5f30e463933c0a0dddfecb22f31ace76c25efaf7a1834cd81575379828bc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.23] - 2026-11-18
4
+
5
+ ### Fixed
6
+
7
+ From the round of cloud-warehouse connection testing, and the Snowflake identifier work that followed it.
8
+
9
+ - **Listing tables and columns repeated itself on Snowflake**: `datasource tables` and `datasource meta` scanned every schema in the database, so against the TPC-DS sample `ITEM` came back once per TPC-DS schema and `LINEITEM` once per TPC-H schema, and a 22 column table reported 44 columns -- enough to build a duplicated model from. Fixed in dwh 0.6.6, which this release requires.
10
+ - **Secrets echoed while being typed**: the Snowflake personal access token, the AWS secret access key and the Databricks OAuth client secret used the plain prompt, so they appeared on screen in full and stayed in terminal history and in any screen share. All three are masked now, as the password prompt always was.
11
+ - **`ds test` told scripts a failed test had passed**: the spinner's "Failed to connect." only draws on a TTY, so in a pipe, a CI run or an AI agent a failure printed nothing and the command still exited zero. It now emits the error in machine-readable form and exits non-zero.
12
+ - **`datasource tables -p` matched case-sensitively**: on a warehouse that reports its names folded, `-p item` found nothing against a table listed as `ITEM`. The pattern now ignores case, using the `TableFilter` helper the interactive model picker already uses.
13
+ - **`ds auth` reported success when it saved nothing**: credentials that were never written still printed as stored.
14
+ - **`datasource add` left the tree dirty for deploy**: deploy now names the paths it refuses, and tells you to commit `datasources.yml`.
15
+ - **The Snowflake template shipped values that looked real**: `datasource add snowflake` wrote `warehouse: COMPUTE_WH` and `role: ACCOUNTADMIN`. Unlike the neighbouring `myorg-myaccount`, both read as working values and were left in place -- and a trial is not always created with `COMPUTE_WH`, so the first connection failed on a setting the user never chose. Both are placeholders now, with a read-only role recommended in the comments.
16
+
3
17
  ## [0.1.22] - 2026-11-05
4
18
 
5
19
  ### Fixed
@@ -37,18 +37,18 @@ module Strata
37
37
 
38
38
  case auth_mode
39
39
  when "pat"
40
- credentials["personal_access_token"] = @prompt.ask("Enter Personal Access Token:")
40
+ credentials["personal_access_token"] = @prompt.mask("Enter Personal Access Token:")
41
41
  when "kp"
42
42
  credentials["username"] = @prompt.ask("Enter Username:")
43
43
  credentials["private_key"] = read_secret_file("Private key path (the PEM contents are stored):")
44
44
  end
45
45
  when "athena"
46
46
  credentials["access_key_id"] = @prompt.ask("AWS Access Key ID:")
47
- credentials["secret_access_key"] = @prompt.ask("AWS Secret Access Key:")
47
+ credentials["secret_access_key"] = @prompt.mask("AWS Secret Access Key:")
48
48
  when "databricks"
49
49
  credentials["auth_mode"] = "oauth_m2m"
50
50
  credentials["oauth_client_id"] = @prompt.ask("OAuth Client ID:")
51
- credentials["oauth_client_secret"] = @prompt.ask("OAuth Client Secret:")
51
+ credentials["oauth_client_secret"] = @prompt.mask("OAuth Client Secret:")
52
52
  when "clickhouse"
53
53
  credentials["password"] = @prompt.mask("Enter Password (leave blank if none):")
54
54
  when "bigquery"
@@ -65,11 +65,19 @@ module Strata
65
65
  @credentials = credentials
66
66
  end
67
67
 
68
+ # Whether collect gathered anything write_local will actually store --
69
+ # blank answers (an empty BigQuery keyfile path) are dropped, so a caller
70
+ # cannot report a save without asking.
68
71
  def collected?
69
- !@credentials.keys.empty?
72
+ @credentials.to_h.any? { |_, val| !val.to_s.empty? }
70
73
  end
71
74
 
72
75
  def write_local(ds_key, context)
76
+ # Nothing to store: leave the existing block alone. Writing would replace a
77
+ # working credential with an empty one -- a stray Enter at the keyfile
78
+ # prompt must not cost the user the key they already had.
79
+ return unless collected?
80
+
73
81
  context.gsub_file Configuration::STRATA_CONFIG_FILE, Utils.yaml_block_matcher(ds_key), ""
74
82
  values = credentials.reject { |_, val| val.nil? || val.to_s.empty? }
75
83
 
@@ -102,7 +110,7 @@ module Strata
102
110
  def bigquery_service_account
103
111
  path = @prompt.ask("Service account keyfile path:").to_s.strip
104
112
  if path.empty?
105
- say " No keyfile given, so no BigQuery credentials were saved. Run `strata ds auth <key>` with the service account keyfile before deploying.", :yellow
113
+ say " No keyfile given, so no BigQuery credentials were saved locally. Deploy leaves whatever the server already holds in place -- run `strata ds auth <key>` with the keyfile to set them from here.", :yellow
106
114
  return {}
107
115
  end
108
116
 
@@ -24,14 +24,16 @@
24
24
  # Required: Database name
25
25
  database: ANALYTICS_DB
26
26
 
27
- # Optional: Warehouse name
28
- warehouse: COMPUTE_WH
27
+ # Optional: Warehouse name. A trial account is created with
28
+ # SNOWFLAKE_LEARNING_WH; COMPUTE_WH is not always there.
29
+ warehouse: MY_WAREHOUSE
29
30
 
30
- # Optional: Schema name
31
+ # Optional: Schema name. Worth setting -- without it, listing tables and
32
+ # columns spans every schema in the database.
31
33
  schema: PUBLIC
32
34
 
33
- # Optional: Role name
34
- role: ACCOUNTADMIN
35
+ # Optional: Role name. Give Strata a read-only role.
36
+ role: MY_READ_ONLY_ROLE
35
37
 
36
38
  # Required: Authentication mode - one of: pat, kp
37
39
  # pat: personal_access_token
@@ -9,6 +9,7 @@ require "tty-prompt"
9
9
  require_relative "../helpers/datasource_helper"
10
10
  require_relative "../helpers/prompts"
11
11
  require_relative "../helpers/description_helper"
12
+ require_relative "../helpers/table_filter"
12
13
  require_relative "../agent_mode"
13
14
 
14
15
  module Strata
@@ -104,6 +105,12 @@ module Strata
104
105
  generator.invoke_all
105
106
 
106
107
  say "\n✔ Added #{adapter} config to datasources.yml", :green
108
+ # datasources.yml is tracked and `deploy` refuses a dirty tree, so say it
109
+ # here rather than let the user hit that refusal from another command.
110
+ # `init` commits the whole project itself, so it does not need the hint.
111
+ if Utils::Git.git_repo? && !options["from_init"]
112
+ say " Commit it before deploying: git add datasources.yml && git commit -m \"Add #{ds_key} datasource\"", :cyan
113
+ end
107
114
 
108
115
  # Automatically collect credentials if required
109
116
  creds = Credentials.new(adapter, datasource_config: config)
@@ -123,7 +130,11 @@ module Strata
123
130
  say ""
124
131
  creds.collect
125
132
  creds.write_local(ds_key, self)
126
- say "\n✔ Credentials saved to .strata file", :green
133
+ if creds.collected?
134
+ say "\n✔ Credentials saved to .strata file", :green
135
+ else
136
+ say "\n No credentials saved for '#{ds_key}'. Run `strata ds auth #{ds_key}` before deploying.", :yellow
137
+ end
127
138
  else
128
139
  say "\n No credentials required for #{adapter}.", :yellow
129
140
  end
@@ -176,6 +187,11 @@ module Strata
176
187
  creds.collect
177
188
  creds.write_local(ds_key, self)
178
189
 
190
+ unless creds.collected?
191
+ say "No credentials saved locally for '#{ds_key}'. Deploy leaves whatever the server already holds in place; re-run this command to replace them.", :yellow
192
+ return
193
+ end
194
+
179
195
  say "Credentials saved successfully to .strata file.", :green
180
196
  end
181
197
 
@@ -187,7 +203,11 @@ module Strata
187
203
  failed_message: "Failed to connect.") do
188
204
  adapter.test_connection(raise_exception: true)
189
205
  end
206
+ AgentOutput.emit_json({datasource: ds_key, connected: true}) if agent_mode?
190
207
  rescue => e
208
+ # The spinner's "Failed to connect." only reaches a TTY, so a pipe or CI run would
209
+ # otherwise see an empty success. Exit non-zero so a script can tell the difference.
210
+ AgentOutput.emit_error(e.message, code: "connection_failed", datasource: ds_key) if agent_mode?
191
211
  say "\t!! Failed to connect: \n\t#{e.message}", :red
192
212
  # datasources[] rather than ds_config: an unknown key is one of the ways we
193
213
  # get here, and ds_config raises on it.
@@ -195,6 +215,7 @@ module Strata
195
215
  say "\tThat path is not on this machine. If it lives inside the Strata container " \
196
216
  "(like the sample's /data/tpcds.duckdb), the server opens it at deploy and this is expected.", :yellow
197
217
  end
218
+ exit 1
198
219
  end
199
220
 
200
221
  desc "tables DS_KEY", "List tables from DS_KEY datasource"
@@ -208,7 +229,7 @@ module Strata
208
229
 
209
230
  adapter = create_adapter(ds_key)
210
231
  tables = adapter.tables(**adapter_qualifiers)
211
- tables = tables.select { it =~ /#{options[:pattern]}/ } if options[:pattern]
232
+ tables = TableFilter.filter(tables, options[:pattern])
212
233
 
213
234
  if agent_mode?
214
235
  AgentOutput.emit_json({datasource: ds_key, tables: tables})
@@ -331,9 +352,9 @@ module Strata
331
352
  {
332
353
  "account_identifier" => "myorg-myaccount",
333
354
  "database" => "ANALYTICS_DB",
334
- "warehouse" => "COMPUTE_WH",
355
+ "warehouse" => "MY_WAREHOUSE",
335
356
  "schema" => "PUBLIC",
336
- "role" => "ACCOUNTADMIN",
357
+ "role" => "MY_READ_ONLY_ROLE",
337
358
  "auth_mode" => "pat"
338
359
  }
339
360
  when "postgres"
@@ -256,10 +256,14 @@ module Strata
256
256
  end
257
257
 
258
258
  def ensure_working_tree_clean
259
- return unless Utils::Git.git_repo?
260
- return unless Utils::Git.uncommitted_changes?
261
-
262
- raise Strata::CommandError, "You have uncommitted changes. Please commit or stash them before deploying."
259
+ paths = Utils::Git.uncommitted_paths
260
+ return if paths.empty?
261
+
262
+ # Name the paths: `ds add` writes a tracked datasources.yml, so the most
263
+ # common cause of this refusal is a change the CLI itself just made.
264
+ raise Strata::CommandError,
265
+ "You have uncommitted changes. Please commit or stash them before deploying:\n " \
266
+ "#{paths.join("\n ")}"
263
267
  end
264
268
 
265
269
  def run_git_status_checks(branch_name)
@@ -274,10 +274,16 @@ module Strata
274
274
  end
275
275
 
276
276
  def uncommitted_changes?
277
- return false unless git_repo?
277
+ !uncommitted_paths.empty?
278
+ end
279
+
280
+ # The paths behind uncommitted_changes?, so a caller that refuses to run
281
+ # can name them. Porcelain's status is the first two columns plus a space.
282
+ def uncommitted_paths
283
+ return [] unless git_repo?
278
284
 
279
285
  stdout, = Open3.capture3("git", "status", "--porcelain")
280
- !stdout.strip.empty?
286
+ stdout.lines.map { |line| line[3..].to_s.strip }.reject(&:empty?)
281
287
  end
282
288
 
283
289
  def fetch_branch(branch_name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Strata
4
4
  module CLI
5
- VERSION = "0.1.22"
5
+ VERSION = "0.1.23"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strata-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ajo Abraham
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.2
19
+ version: 0.6.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.6.2
26
+ version: 0.6.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: aws-sdk-athena
29
29
  requirement: !ruby/object:Gem::Requirement