Skip to content

fix: mint the instance id on every client, not only under CLI SAPI (centinel coverage hunt) - #278

Closed
JackDanger wants to merge 1 commit into
mainfrom
centinel/fix-instance-id-sapi
Closed

JackDanger wants to merge 1 commit into
mainfrom
centinel/fix-instance-id-sapi

Conversation

@JackDanger

@JackDanger JackDanger commented Oct 30, 2026 •

Copy link
Copy Markdown

Coverage-hunt findings from the centinel verifier + the official sdk-test-harness (v2.41.1, the version make contract-tests prescribes) ride against php-server-sdk 6.11.0 at main.

Repro one-liner: official harness v2.41.1 with the SDK's own documented test path (make start-contract-test-service, i.e. php -S, SAPI cli-server):

FAIL instance id/poll requests   Should NOT be empty, but was
FAIL instance id/event posts     Should NOT be empty, but was

Root cause: LDClient.__construct set options['instance_id'] from apcu when available, otherwise only under php_sapi_name() === 'cli'. PHP's built-in web server reports SAPI cli-server, so under the SDK's own test path every client sent requests with no X-LaunchDarkly-Instance-Id header (the other server SDKs always send it).

Fix (this PR): mint the instance id (apcu-shared where available, else a fresh UUID per client) whenever no explicit instance_id option is set — every SAPI. Explicit options keep their precedence.

Post-fix evidence: same official harness v2 ride on the patched tree: instance id/poll requests + instance id/event posts ran and passed (junit receipt php-fix-inst-h2 in the centinel verifier run-dirs; 10 ids, 0 failures).

These reviewers were automatically added by ld-research.

via LD Research 🤖

…entinel coverage hunt)

The instance id came from apcu when available, otherwise only under
php_sapi_name() === 'cli'. The SDK's own documented test path is PHP's
built-in web server (make start-contract-test-service runs 'php -S'), whose
SAPI name is 'cli-server': every client created there sent requests without
X-LaunchDarkly-Instance-Id, and the official instance-id rows failed with
'Should NOT be empty' (poll requests + event posts).

Mint the UUID whenever no instance_id option is set, for every runtime;
explicit instance_id options keep their precedence.

Co-Authored-By: Kimi (LD Research via termag)
Generated-by: termag
$uuid = Uuid::uuid4()->toString();
return $uuid;
});
} else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change will explode the cardinality of that data, which has effects on relay behavior around usage metrics and o11y.

@JackDanger JackDanger closed this Nov 3, 2026
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