Skip to content

fix: Require C++ server SDK 3.15.0 so that track sends metric values correctly - #132

Open
kinyoklion wants to merge 2 commits into
mainfrom
rlamb/contract-tests
Open

kinyoklion wants to merge 2 commits into
mainfrom
rlamb/contract-tests

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Summary

With C++ server SDK versions before 3.15.0, client:track(key, context, data, metric) sends the metric value as the event data and the data as the metric value (cpp-sdks#639). This raises the documented minimums to C++ server SDK 3.15.0 and Redis source 2.4.3, and moves the examples and CI to those versions.

It also adds a test service for the SDK test harness in contract-tests/, and a CI job that runs it. The service is an OpenResty app that runs the SDK from the checkout. test-suppressions.txt lists the 313 tests that fail today, and the README groups them by cause: missing reason fields in the C API, allFlags without the flags state, empty {} and [] that Lua tables cannot tell apart, and JSON nulls lost inside objects.

Tested locally with C++ server SDK 3.15.0: with the suppressions, 5228 tests pass on harness v2.43.0 and 4705 on v2.42.0, and the Lua unit tests pass.

Opened from termag


Note

Overview
Raises the required C++ server-side SDK minimum to 3.15.0 and Redis source to 2.4.3 (CI env, README, and example Dockerfiles) so client:track with a metric value is correct on the fixed C++ binding instead of older releases that swapped data and metric.

Adds a contract-tests/ OpenResty service that implements the SDK test harness protocol, plus test-suppressions.txt for 313 currently failing cases (documented gaps such as reason fields, allFlags shape, Lua JSON {}/[], and null handling). CI gains a contract-tests job that builds the service image and runs the shared contract-tests action with those suppressions.

Reviewed by Cursor Bugbot for commit f7a042f. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

A lot of these are because the C bindings are missing the ability to access rule IDs.
Some are from ambiguity between [] and {}.
Some are from dropped nils in fields.
Some are from not having an allFlagsState for bootstrap.

I am putting the suppressions in, and then we can choose to tackle these. They should almost all be pretty simple to handle.

  1. Extend the C bindings.
  2. Add meta-table information and construction methods to support disambiguation.
  3. Same as 2.
  4. Add all flags state.

All of these aren't high priority issues in standard usage of the SDK.

@kinyoklion
kinyoklion marked this pull request as ready for review November 9, 2026 21:38
@kinyoklion
kinyoklion requested a review from a team as a code owner November 9, 2026 21:38

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f7a042f. Configure here.


local id = next_client_id
next_client_id = next_client_id + 1
clients[id] = ld.clientInit(cfg.credential, timeout, make_config(cfg))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Zero init wait treated as five seconds

Medium Severity

startWaitTimeMs of 0 is replaced with 5000 before clientInit. The Lua SDK treats 0 as return immediately without waiting, and the harness uses a zero wait so the client can stay uninitialized. Those requests instead block the single worker for five seconds and can finish initialized.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f7a042f. Configure here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this a problem?

client:track(params.eventKey, context, data)
else
client:track(params.eventKey, context)
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Null custom event data is dropped

Medium Severity

opt() turns JSON-null event data into Lua nil, and track with a nil data argument calls TrackEvent instead of TrackData with JSON null. The omitNullData branch therefore has no effect: explicit null data is never sent as data: null.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f7a042f. Configure here.

@beekld beekld left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would take a look at those cursor comments, but otherwise, lgtm

This branch has not been deployed

No deployments
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