Skip to content

✨ feat: set ClientToken if not already set by client#1077

Open
jobs62 wants to merge 1 commit into
v3from
test/token
Open

✨ feat: set ClientToken if not already set by client#1077
jobs62 wants to merge 1 commit into
v3from
test/token

Conversation

@jobs62

@jobs62 jobs62 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Description

set idempotency token automaticly to a new UUIDv7 if not already set by the application. this is done to avoid issues of ressources created multiple times when retrying on a brittle connection.

Type of Change

Please check the relevant option(s):

  • 🐛 Bug fix
  • ✨ New feature
  • 🧹 Code cleanup or refactor
  • 📝 Documentation update
  • 🔧 Build or CI-related change
  • 🔒 Security fix
  • Other (specify):

How Has This Been Tested?

Please describe the test strategy:

  • Manual testing
  • Unit tests
  • Integration tests
  • Not tested yet

Checklist

  • I have followed the Contributing Guidelines
  • I have added tests or explained why they are not needed
  • I have updated relevant documentation (README, examples, etc.)
  • My changes follow the Conventional Commits specification
  • My commits include appropriate Gitmoji

@jobs62
jobs62 marked this pull request as ready for review March 31, 2026 14:57
@jobs62
jobs62 requested a review from jfbus April 2, 2026 18:22
Comment thread pkg/oks/client.go
}, nil
}

type clientTokenSetter interface {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hesitate. on one hand this is stutter, and the interface appears multiple times (=> a shared interface could do the job). on the other hand, adding a new package for this is maybe too much

Comment thread pkg/oks/client.gen.go
if v, ok := any(body).(clientTokenSetter); ok {
err := v.SetClientToken()
if err != nil {
return nil, err

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should log and continue... why would it be an error if this thing that the user has not asked for and is not required fails ?

Comment thread pkg/osc/client_test.go
}

require.NoError(t, data.SetClientToken())
require.NotNil(t, data.ClientToken, "ClientToken should be set by mutateBody")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert.NotEmpty(t, data.ClientToken) (it could be not nil but empty)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants