Secrets: Tavern fails to start when the secrets file exists but doesn't contain tavern_ed25519_private_key
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read tavern/internal/crypto/crypto.go and tavern/internal/secrets/debug_file.go to trace how a missing key is handled. Reproduce with an empty secrets file and one containing other keys, then add tests around GetPrivKeyED25519 for both cases. Done means startup generates and stores a key when the requested key is absent, and the tests pass.
Written by the indexing model from the issue text.
Description
Summary
crypto.getKeyPair (tavern/internal/crypto/crypto.go) only generates and stores a new ED25519 key when SecretsManager.GetValue returns an error. DebugFileSecrets.GetValue (tavern/internal/secrets/debug_file.go) returns ([]byte{}, nil) when the secrets file exists but doesn't contain the requested key. getKeyPair then skips key generation and fails the key-size check:
invalid ED25519 private key size: got 0, expected 64
Reproduce
touch /tmp/secrets.yaml
SECRETS_FILE_PATH=/tmp/secrets.yaml go run ./tavern
The same happens with a non-empty secrets file that holds other keys but not tavern_ed25519_private_key.
When the file does not exist at all, GetValue returns os.ErrNotExist, a key is generated and SetValue creates the file, so the common fresh-start case works.
Current behavior by case
- No file: works (key generated, file created).
- File with the key: works.
- Non-empty file without the key: fails with the key-size error above.
- Empty file (e.g. created with
touch): onmain,getYamlStructreturns a bareio.EOF, soGetValueerrors, a key is generated, andSetValuethen fails withEOF. With theio.EOFhandling proposed in #2508 it fails with the key-size error instead.
I confirmed the empty-file key-size failure with a throwaway test against the #2508 branch (GetPrivKeyED25519 on an empty DebugFileSecrets file). The main behavior is from reading the code, not from running it.
Suggested fix
Either of:
DebugFileSecrets.GetValuereturns a not-found error when the key is missing, matching the other secrets managers; orgetKeyPairtreats a zero-length value as "missing" and generates a key.
Add a test that calls GetPrivKeyED25519 against an empty secrets file and against a file that holds only other keys.
Related
Found during review of #2508. Separate from that PR's scope.
- Dominant language
- Rust
- Stars
- 639
- Forks
- 65
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 62
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spellshift/realm
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
spellshift/realm#1574 · 3 comments ·
Maintainers usually reply within 1 day
-
feature
Difficulty 3/5 1-2 days Newbie friendliness 55/100
spellshift/realm#2461 · 1 comment ·
Maintainers usually reply within 1 day
-
feature
Difficulty 5/5 Over a week Newbie friendliness 15/100
spellshift/realm#2449 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
spellshift/realm#2424 ·
Maintainers usually reply within 1 day
-
feature
Difficulty 5/5 Over a week Newbie friendliness 22/100
spellshift/realm#2357 ·
Maintainers usually reply within 1 day
All issues in spellshift/realm
Similar issues
-
<input type="number"> misses text-entry leaf sizing in layoutPossibly taken @GoCoder7 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
DioxusLabs/blitz#1675 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
metasequoiaime/msime#11666 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
bug drawings help wanted ui
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
userFRM/egui-charts#3479 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
s2-streamstore/cachey#225 ·
Maintainers usually reply within 1 day