Skip to content

feat(application): add --share-token to run commands - #688

Open
dima-aignostics wants to merge 4 commits into
mainfrom
feat/PYSDK-145-read-run-with-share-token
Open

feat(application): add --share-token to run commands#688
dima-aignostics wants to merge 4 commits into
mainfrom
feat/PYSDK-145-read-run-with-share-token

Conversation

@dima-aignostics

@dima-aignostics dima-aignostics commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Add --share-token argument to next commands to the uvx aignostics application run group:

describe
dump-metadata
dump-item-metadata
result download

@dima-aignostics
dima-aignostics requested a review from a team as a code owner June 22, 2026 08:46
@dima-aignostics
dima-aignostics force-pushed the feat/PYSDK-145-read-run-with-share-token branch 4 times, most recently from b524be7 to 9510e92 Compare June 22, 2026 11:36
@dima-aignostics
dima-aignostics force-pushed the feat/PYSDK-132-add-run-sharing-to-python-sdk branch 6 times, most recently from 6ae872e to 0bc4980 Compare June 23, 2026 21:15
Base automatically changed from feat/PYSDK-132-add-run-sharing-to-python-sdk to main June 29, 2026 08:04
@dima-aignostics
dima-aignostics force-pushed the feat/PYSDK-145-read-run-with-share-token branch 3 times, most recently from 5ab4c44 to 23c6793 Compare June 30, 2026 14:04
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.58333% with 5 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/aignostics/application/_cli.py 89.47% 1 Missing and 1 partial ⚠️
src/aignostics/application/_service.py 66.66% 1 Missing and 1 partial ⚠️
src/aignostics/application/_utils.py 83.33% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
src/aignostics/platform/resources/runs.py 86.57% <100.00%> (+1.05%) ⬆️
src/aignostics/application/_utils.py 88.72% <83.33%> (-0.17%) ⬇️
src/aignostics/application/_cli.py 79.33% <89.47%> (+1.11%) ⬆️
src/aignostics/application/_service.py 63.73% <66.66%> (-0.08%) ⬇️

... and 3 files with indirect coverage changes

…DK-145)

Recipients holding a share token secret can now describe a run without
OAuth login by passing --share-token <secret> to `application run describe`.
The token is used directly as the Bearer token for platform API requests.

- Adds `--share-token` option to `run describe`; when set, creates a
  `Client(token_provider=…)` bypassing OAuth, with `hide_platform_queue_position=True`
- Catches `UnauthorizedException` and `ForbiddenException` when using a share
  token and surfaces a clear "Access denied" message with exit code 1
- Adds 5 integration tests covering success (text + JSON), not-found,
  unauthorized, and forbidden paths

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dima-aignostics
dima-aignostics force-pushed the feat/PYSDK-145-read-run-with-share-token branch from 23c6793 to c3c99ef Compare June 30, 2026 15:38
@dima-aignostics dima-aignostics changed the title feat(application): add --share-token to run describe CLI command (PYS… feat(application): add --share-token to run commands Jul 1, 2026
@dima-aignostics
dima-aignostics force-pushed the feat/PYSDK-145-read-run-with-share-token branch from 01154f0 to 8bad631 Compare July 1, 2026 11:23
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

olivermeyer and others added 2 commits August 3, 2026 15:43
Resolve conflict in application/_cli.py: keep both the --share-token
option (this branch) and the --show-checksum option (main) on the
run dump-metadata and dump-item-metadata commands. The command bodies
already reference both parameters; only the signatures collided.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a --share-token option to `application run describe / dump-metadata /
dump-item-metadata / result download` (PYSDK-145), granting an authenticated
user access to a run that has been shared with them.

- Share-token access still authenticates as the calling user: the platform
  requires an OAuth Bearer token on every request. The share_token is forwarded
  as the `share_token` query parameter (on details/results and the artifact
  /file endpoint) and elevates that user's access to the shared run. Run.for_run_id
  and the artifact download path therefore keep the normal authenticated client
  and always send the Bearer header.
- 403 handling: re-raise ForbiddenException before the generic
  ApiException->RuntimeError wrapper in application_run_download so the CLI
  surfaces the share-token access-denied message.
- Percent-encode the share_token in the artifact /file URL so reserved
  characters cannot corrupt the URL or inject extra query parameters.
- Remove three unrelated runtime dependencies (joserfc, python-engineio,
  python-socketio) that were added but never imported; re-lock.
- DRY: extract share_token_access_denied_message() helper and a single
  ShareTokenOption alias (consistent help text across all four commands).
- Rename the misleading _share_token cache-key parameter to share_token.
- Add resource-, CLI-, and service-layer tests covering token forwarding,
  URL encoding, the Bearer header being sent alongside the share_token,
  authenticated-client wiring, exit-2 not-found paths, and the 403 re-raise.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@olivermeyer
olivermeyer force-pushed the feat/PYSDK-145-read-run-with-share-token branch from 13331ff to d8936d0 Compare August 3, 2026 15:00
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

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.

2 participants