Skip to content

fix: read PRIOMPT_TOKEN, regenerate stubs from priompt/proto, scrub name - #9

Merged
sujal-maheshwari2004 merged 1 commit into
mainfrom
fix/5-token-stubs-name
Oct 18, 2026
Merged

sujal-maheshwari2004 merged 1 commit into
mainfrom
fix/5-token-stubs-name

Conversation

@sujal-maheshwari2004

Copy link
Copy Markdown
Contributor

What was wrong

  • PromptClient ignored PRIOMPT_TOKEN, so a client with only PRIOMPT_TOKEN set got UNAUTHENTICATED. The priompt CLI reads that variable.
  • The checked-in prompt_pb2.py descriptor still carried the old go_package (priomptproto/gen/priompt/v1;priomptv1).
  • The README example used a real person's name.

Fix

  • Token precedence is now token=, then PRIOMPT_TOKEN, then the token in url=/PRIOMPT_URL. That's the same order as the priompt CLI (authCtx prefers PRIOMPT_TOKEN over the URL token).
  • Regenerated the stubs with buf generate from priompt/proto @ e7dce07, then applied the documented relocation and import fix. prompt_pb2.py changes only in the serialized descriptor and the go_package option, which is now github.com/priompt/proto/gen/priompt/v1;priomptv1. prompt_pb2_grpc.py regenerates byte-identical, so it is unchanged. The wire paths /priompt.v1.PromptService/* are untouched.
  • buf.gen.yaml now pins buf.build/protocolbuffers/python:v35.1. Unpinned, the plugin now emits 7.36.2 gencode, which would reject the protobuf>=7.35 runtimes that pyproject.toml allows. With the pin, the gencode stays at 7.35.1.
  • README: name="Sujal" is now name="Ada", and the token row documents the PRIOMPT_TOKEN default.

Tests

New tests are test_reads_priompt_token_env and test_token_precedence.

before the fix: FAILED test_reads_priompt_token_env, FAILED test_token_precedence  (2 failed, 15 passed)
after the fix:  17 passed in 0.26s

Real run against priompt v0.7.2 serve with PRIOMPT_TOKEN=admintok on the server. The client has PRIOMPT_TOKEN=admintok in its environment and no token=:

Before:

{'host': '127.0.0.1:49443'} -> UNAUTHENTICATED invalid or missing token
{'url': 'priompt://127.0.0.1:49443'} -> UNAUTHENTICATED invalid or missing token

After (this also exercises the regenerated stub over the wire):

go_package: github.com/priompt/proto/gen/priompt/v1;priomptv1
{'host': '127.0.0.1:49443'} -> e345dcf74d01
{'url': 'priompt://127.0.0.1:49443'} -> e345dcf74d01

With PRIOMPT_TOKEN=wrong, the client still gets UNAUTHENTICATED, as expected.

Expected conflict

#7 (fix for #3) also appends tests at the end of tests/test_client.py and edits other lines of README.md. Whichever merges second needs a trivial rebase. Keep both test blocks.

Fixes #5

🤖 Generated with Claude Code

- PromptClient now reads PRIOMPT_TOKEN. Precedence matches the priompt
  CLI: token=, then PRIOMPT_TOKEN, then the token in url=/PRIOMPT_URL.
- Regenerate prompt_pb2.py from priompt/proto (e7dce07). The embedded
  descriptor carried the old go_package (priomptproto/gen/...); it now
  says github.com/priompt/proto/gen/priompt/v1. prompt_pb2_grpc.py
  regenerates byte-identical (after the documented import fix), and the
  wire paths are unchanged.
- Pin the protobuf plugin to v35.1 in buf.gen.yaml so regenerated
  gencode keeps working with the protobuf>=7.35 floor (unpinned, it now
  emits 7.36.2 gencode, which rejects an older runtime).
- README: use "Ada" in the example instead of a real name; document the
  token default.

Fixes #5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sujal-maheshwari2004
sujal-maheshwari2004 merged commit 15c774a into main Oct 18, 2026
1 check passed
@sujal-maheshwari2004
sujal-maheshwari2004 deleted the fix/5-token-stubs-name branch October 18, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read PRIOMPT_TOKEN, regenerate stale stubs, scrub real name

1 participant