Skip to content

Commit 8883924

Browse files
authored
Merge pull request #304 from cipherstash/set-keyset-name
Handle SET KEYSET errors with grace and aplomb
2 parents 59eb3f2 + 92ff53a commit 8883924

File tree

25 files changed

+917
-511
lines changed

25 files changed

+917
-511
lines changed

.claude/commands/commit.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ Or with options:
1717
## What This Command Does
1818

1919
1. Unless specified with `--no-verify`, automatically runs pre-commit checks:
20-
- `cargo clippy` to ensure code quality
21-
- `cargo check` to verify the build succeeds
22-
- `cargo fmt --check` to ensure consistent code formatting
20+
- `mise run check`
2321
2. Checks which files are staged with `git status`
2422
3. If 0 files are staged, automatically adds all modified and new files with `git add`
2523
4. Performs a `git diff` to understand what changes are being committed

.github/actions/setup-test/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ runs:
77
using: composite
88
steps:
99
- uses: actions/checkout@v4
10+
1011
- name: Install rust
1112
shell: /bin/bash -l {0}
1213
run: rustup toolchain install stable --profile minimal --no-self-update
1314
- name: Setup Rust cache
1415
uses: Swatinem/rust-cache@v2
1516
with:
16-
cache-provider: buildjet
17+
cache-provider: ${{ inputs.provider }}
18+
shared-key: ${{ inputs.key }}
1719
cache-all-crates: true
1820
- uses: jdx/mise-action@v2
1921
with:
2022
version: 2025.1.0 # [default: latest] mise version to install
2123
install: true # [default: true] run `mise install`
2224
cache: true # [default: true] cache mise using GitHub's cache
25+

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434

3535
RUST_BACKTRACE: "1"
3636
run: |
37-
mise run --output prefix test
37+
mise run --output prefix test

CLAUDE.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ mise run reset
7676
# Full test suite (hygiene + unit + integration)
7777
mise run test
7878

79+
# Hygiene checks only
80+
mise run check
81+
7982
# Unit tests only
8083
mise run test:unit [test_name]
8184

@@ -111,7 +114,7 @@ Proxy requires CipherStash credentials configured in `mise.local.toml`:
111114
CS_WORKSPACE_CRN = "crn:region:workspace-id"
112115
CS_CLIENT_ACCESS_KEY = "your-access-key"
113116
CS_DEFAULT_KEYSET_ID = "your-keyset-id"
114-
CS_CLIENT_ID = "your-client-id"
117+
CS_CLIENT_ID = "your-client-id"
115118
CS_CLIENT_KEY = "your-client-key"
116119
```
117120

@@ -136,7 +139,7 @@ Available targets: `DEVELOPMENT`, `AUTHENTICATION`, `CONTEXT`, `ENCRYPT`, `KEYSE
136139

137140
### Error Handling
138141
- All errors defined in `packages/cipherstash-proxy/src/error.rs`
139-
- Errors grouped by problem domain (not module structure)
142+
- Errors grouped by problem domain (not module structure)
140143
- Customer-facing errors include friendly messages and documentation links
141144
- Use descriptive variant names without "Error" suffix
142145

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ debug = true
4343

4444
[workspace.dependencies]
4545
sqltk = { version = "0.10.0" }
46-
cipherstash-client = "0.26.0"
46+
cipherstash-client = "0.27.0"
4747
cts-common = { version = "0.3.0" }
4848
thiserror = "2.0.9"
4949
tokio = { version = "1.44.2", features = ["full"] }

DEVELOPMENT.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ stash access-keys create proxy
5050
# add to CS_CLIENT_ACCESS_KEY
5151

5252
# Create a dataset
53-
stash datasets create proxy
53+
stash keysets create proxy
5454
# add to CS_DEFAULT_KEYSET_ID
5555

5656
# Create a client
@@ -409,6 +409,9 @@ The integration tests have several runtime dependencies:
409409
- Running PostgreSQL instances (that can be started with `mise run postgres:up`)
410410
- Credentials for CipherStash ZeroKMS (which can be found in the [quickstart](#developing) section)
411411

412+
The `Multitenant` Integration tests require different configuration from the baseline.
413+
The `CS_DEFAULT_KEYSET_ID` value must not be set for the multitenant `SET KEYSET_*` commands to work.
414+
412415
##### Language-specific integration tests
413416

414417
To run language-specific integration tests, call:

docs/errors.md

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
- [Column could not be encrypted](#encrypt-column-could-not-be-encrypted)
1818
- [Column could not be encrypted](#encrypt-column-could-not-be-encrypted)
1919
- [Could not decrypt data for keyset](#encrypt-encrypt-could-not-decrypt-data-for-keyset)
20+
- [KeysetId could not be parsed](#encrypt-keyset-id-could-not-be-parsed)
2021
- [KeysetId could not be set](#encrypt-keyset-id-could-not-be-set)
22+
- [KeysetName could not be set](#encrypt-keyset-name-could-not-be-set)
2123
- [Plaintext could not be encoded](#encrypt-plaintext-could-not-be-encoded)
2224
- [Unknown column](#encrypt-unknown-column)
2325
- [Unknown table](#encrypt-unknown-table)
@@ -276,31 +278,81 @@ The most likely cause is network access to the ZeroKMS service.
276278

277279

278280

281+
<!-- ---------------------------------------------------------------------------------------------------- -->
282+
283+
284+
## KeysetId could not be parsed <a id='encrypt-keyset-id-could-not-be-parsed'></a>
285+
286+
A keyset_id could not be parsed using the `SET CIPHERSTASH.KEYSET_ID` command.
287+
288+
### Error message
289+
290+
```
291+
KeysetId `{id}` could not be parsed using `SET CIPHERSTASH.KEYSET_ID`. KeysetId should be a valid UUID.
292+
```
293+
294+
### How to Fix
295+
296+
1. Check that the `KeysetId` is a valid UUID.
297+
298+
299+
```
300+
SET [ SESSION ] CIPHERSTASH.KEYSET_ID { TO | = } '{KeysetId}'
301+
```
302+
279303
<!-- ---------------------------------------------------------------------------------------------------- -->
280304

281305

282306
## KeysetId could not be set <a id='encrypt-keyset-id-could-not-be-set'></a>
283307

284-
A keyset_id could not be set using the `SET CIPHERSTASH.KEYSET_ID` command.
308+
A KeysetId could not be set using the `SET CIPHERSTASH.KEYSET_ID` command.
285309

286310

287311
### Error message
288312

289313
```
290-
A keyset_id could not be set using `SET CIPHERSTASH.KEYSET_ID`
314+
A KeysetId could not be set using `SET CIPHERSTASH.KEYSET_ID`
291315
```
292316

293317
### How to Fix
294318

295-
1. Check the syntax of the `SET CIPHERSTASH.KEYSET_ID` command. The `keyset_id` value should be in single quotes.
296-
2. Check that the provided `keyset_id` is a valid UUID.
297-
2. Check that the value is being set as a literal. The PostgreSQL `SET` statement does not support parameterised querying.
319+
1. Check the syntax of the `SET CIPHERSTASH.KEYSET_ID` command. The `KeysetId` value should be in single quotes.
320+
2. Check that the `KeysetId` is a valid UUID.
321+
3. Check that the value is being set as a literal. The PostgreSQL `SET` statement does not support parameterised querying.
298322

299323

300324
```
301325
SET [ SESSION ] CIPHERSTASH.KEYSET_ID { TO | = } '{keyset_id}'
302326
```
303327

328+
329+
<!-- ---------------------------------------------------------------------------------------------------- -->
330+
331+
332+
## KeysetName could not be set <a id='encrypt-keyset-name-could-not-be-set'></a>
333+
334+
KeysetName could not be set using the `SET CIPHERSTASH.KEYSET_NAME` command.
335+
336+
337+
### Error message
338+
339+
```
340+
A KeysetName could not be set using `SET CIPHERSTASH.KEYSET_NAME`
341+
```
342+
343+
### How to Fix
344+
345+
1. Check the syntax of the `SET CIPHERSTASH.KEYSET_ID` command. The `KeysetName` value should be in single quotes.
346+
2. Check that the provided `KeysetName` is a valid UUID.
347+
2. Check that the value is being set as a literal. The PostgreSQL `SET` statement does not support parameterised querying.
348+
349+
350+
```
351+
SET [ SESSION ] CIPHERSTASH.KEYSET_NAME { TO | = } '{KeysetName}'
352+
```
353+
354+
355+
304356
<!-- ---------------------------------------------------------------------------------------------------- -->
305357

306358

0 commit comments

Comments
 (0)