aws-samples / aws-samples/sample-autonomous-cloud-coding-agents

fix(jira): prevent CLI webhook-secret updates from losing refreshed OAuth tokens

Open
#724 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
143
Forks
46
Avg merge
3d 9h
Merged PRs (30d)
20

Description

## Problem

`bgagent jira setup` and `bgagent jira update-webhook-secret` read the shared per-tenant OAuth bundle, modify `webhook_signing_secret`, and write the complete bundle back. A concurrent Lambda refresh in `cdk/src/handlers/shared/jira-oauth-resolver.ts` can rotate `refresh_token` between the CLI read and write, allowing the CLI to overwrite the newly rotated token with a stale value and break subsequent Jira authentication. The existing `invite-user` update path has the same read-modify-write pattern.

This was identified as a non-blocking review finding on #710. It is intentionally separate because Secrets Manager `PutSecretValue` does not provide a simple version-conditioned compare-and-swap; `ClientRequestToken` provides idempotency, not protection against overwriting a concurrently created version.

## Acceptance criteria

- Define a concurrency-safe ownership/update strategy for mutable Jira OAuth bundles.
- Prevent CLI updates from replacing a `refresh_token` rotated after the CLI read.
- Preserve webhook and Forge app-actor fields across OAuth refresh and CLI updates.
- Add a test that interleaves a Lambda refresh with each affected CLI update path.
- Document retry/recovery behavior when a concurrent update is detected.

Contributor guide

Open the contributing guide

Research direction

Start with cdk/src/handlers/shared/jira-oauth-resolver.ts and the CLI entry points for bgagent jira setup, update-webhook-secret, and invite-user to map their shared OAuth bundle updates. Add interleaving tests for a Lambda refresh with each CLI path, verify refresh_token, webhook, and Forge fields are preserved, and document retry or recovery behavior when a concurrent update is detected.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
authentication, backend, cli, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.