Skip to content

PAT-1959 Own the runId generator; drop client-wrapper StorageClientRequestFactory#547

Merged
pepamartinec merged 1 commit into
mainfrom
pepa/PAT-1959_noCw
Jul 23, 2026
Merged

PAT-1959 Own the runId generator; drop client-wrapper StorageClientRequestFactory#547
pepamartinec merged 1 commit into
mainfrom
pepa/PAT-1959_noCw

Conversation

@pepamartinec

@pepamartinec pepamartinec commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Release Notes

https://linear.app/keboola/issue/PAT-1959/api-bundle-own-the-runid-generator-drop-client-wrapper

Related storage-api-php-client-branch-wrapper 7.0: keboola/storage-api-php-client-branch-wrapper#39 (PAT-1954)

branch-wrapper 7.0 removed ClientOptions::runIdGenerator (and its get/setRunIdGenerator()) together with Keboola\StorageApiBranch\Factory\StorageClientRequestFactory, so api-bundle's StorageClientRequestFactory::resolveRunId() — which read the generator off ClientOptions — no longer compiles against it. The bundle now owns the generator: StorageClientRequestFactory takes it as an optional ?Closure(ClientOptions): string constructor dependency and resolves from it, with the run id order unchanged — X-KBC-RunId header → configured generator → uniqid('run-').

Because the generator is a closure and therefore not YAML-expressible, consumers inject it through a new keboola_api.storage_client_options.run_id_generator: <service-id> knob, wired in KeboolaApiExtension to the factory's $runIdGenerator argument. The referenced service must resolve to a Closure (exposed via a factory, since Closure is not directly constructible). It is grouped under storage_client_options for config cohesion but — unlike the other keys — is passed to the factory rather than merged into ClientOptions, so it is exempt from the service-vs-individual-options exclusivity and may accompany either form. This replaces the previous approach of setting runIdGenerator on a custom ClientOptions service, which the client wrapper no longer supports.

Key changes:

  • StorageClientRequestFactory owns the run id generator (?Closure ctor dep); no more ClientOptions::getRunIdGenerator().
  • New keboola_api.storage_client_options.run_id_generator config knob + KeboolaApiExtension wiring.
  • keboola/storage-api-php-client-branch-wrapper bumped to ^7.0.
  • README: dropped runIdGenerator from the custom-ClientOptions-service docs; added a "Customizing the run id" section.
  • Audited all StorageApiToken / ClientOptions-with-token construction — every site already passes authType/tokenType, so 7.0's "token requires authType" enforcement is satisfied; no code changes were needed there.

Plans for customer communication

None.

Impact analysis

To be released as api-bundle 6.1.0. It moves the keboola/storage-api-php-client-branch-wrapper requirement to ^7.0; the only service affected by the runId-generator change is runner-sync-api (the sole user of a custom generator), migrated in lockstep via PAT-1960. Any service that injected a run id generator through a custom ClientOptions service must move to the keboola_api.storage_client_options.run_id_generator knob. No end-user (runtime) impact — run id resolution behaviour is unchanged.

Change type

Refactoring

Justification

Adapt api-bundle to storage-api-php-client-branch-wrapper 7.0, which removed ClientOptions::runIdGenerator and Factory\StorageClientRequestFactory.

Deployment

Merge & automatic deploy.

Rollback plan

Revert of this PR.

Post release support plan

None.

@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

PAT-1959

@janvanicek janvanicek left a comment

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.

Jen ten jeden test case, jinak ok

@@ -52,9 +52,10 @@ public function testRunIdFallsBackToGeneratedValueWhenHeaderMissing(): void

public function testRunIdGeneratorUsedWhenHeaderMissing(): void

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.

Přidal bych test na ověření, že run id generator must not be called when the X-KBC-RunId header is present

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added testRunIdGeneratorNotCalledWhenHeaderPresent: the injected generator calls self::fail() if invoked and the request carries X-KBC-RunId: 42, so it asserts the header wins and the generator is never called. Verified it fails with that message when the header short-circuit is removed. 👍

branch-wrapper 7.0 removed ClientOptions::runIdGenerator and its
Factory\StorageClientRequestFactory. StorageClientRequestFactory now takes the
run id generator as its own optional Closure dependency and resolves from it,
preserving the header > generator > uniqid('run-') order. A new
keboola_api.storage_client_options.run_id_generator config knob injects the
generator service; it is grouped with the other Storage client options but wired
to the factory (not merged into ClientOptions), so it may accompany the service
form. This replaces the runIdGenerator on a custom ClientOptions service.
Comment on lines +267 to +269
// -------------------------------------------------------------------------
// run_id_generator
// -------------------------------------------------------------------------

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.

Ještě tohle nevim nevim teda

@pepamartinec
pepamartinec merged commit fbac029 into main Jul 23, 2026
26 checks passed
@pepamartinec
pepamartinec deleted the pepa/PAT-1959_noCw branch July 23, 2026 12:17
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