Repository navigation
Review learning: rule changes from 2026-10-24 to 2026-11-22 - #8644
Closed
dd-apm-ecosystems[bot] wants to merge 4 commits into
Closed
dd-apm-ecosystems[bot] wants to merge 4 commits into
dd-apm-ecosystems[bot] wants to merge 4 commits into
Conversation
Contributor
|
|
robertomonteromiguel
deleted the
review-learning/run-system-tests-2026-10-24-53f75d9d
branch
November 23, 2026 14:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Monthly review learning. 10 changes to the code review rules, learned from the 348 PRs merged from 2026-10-24 to 2026-11-22.
Review them in Files changed, and answer on each rule:
ok,discard, a suggestion, or a comment. Once a day, a workflow applies the answers and replies.🆕 New rules (5)
Rules that the review does not have yet. Open the last cell of a row for what it does, why, a bad and a good example, and the evidence.
META-010Three PRs show manifest versions that enable a test beyond where its behavior holds: a class covered by a file-level floor, a legacy class kept active after ...
What it does: A manifest version must enable a test only where its expected behavior holds. If a file-level version also enables a class, check that the class works from that version. If the behavior changes between versions, give each class its own version range. If a version passes on one weblog only, do not lower it for every weblog.
Why is this bad? Three PRs show manifest versions that enable a test beyond where its behavior holds: a class covered by a file-level floor, a legacy class kept active after a key change, and a bound lowered for all weblogs. No existing rule covers version scope.
Example
Use instead
Gate the class at
v2.11.0-devwhen the file-levelv2.10.0-devcovers a release without drop telemetry.Evidence:
correction: "This activates the legacydd.serialIdclass for every Go version from v2.10.1."correction: "Gate this class atv2.11.0-devfor Go. The file-levelv2.10.0-devalso enables it on v2.10.1, which reports no drop telemetry."correction: "this PR moves them to v1.67.0 for every weblog, ALB included"LIFE-005Two PRs asserted exact counts of asynchronously flushed data.
What it does: Assert an exact count of flushed spans, events, or metrics only after the flush ends. A wait that returns at the expected count misses a late extra item. For scenario-wide data, count only the data of the requests of this test.
Why is this bad? Two PRs asserted exact counts of asynchronously flushed data. One wait returned at the expected count and missed late items. One count covered the whole scenario and raced the flush before teardown. No rule covers this.
Example
Use instead
Wait for the flush window. Then count only the items of the requests of this test.
Evidence:
correction: "This returns as soon as 2 spans show up, so a third evaluation landing in a later flush wouldn't be caught."correction: "so it depends on every metric point being flushed before teardown"LIFE-006Two PRs show assertions that held only inside one wall-clock window: a 10s stats bucket and an API Security sampling window.
What it does: An assertion on a result that depends on a wall-clock window must accept each valid outcome. Stats buckets and sampling windows are such windows. Do not hide this with a
flakymanifest entry.Why is this bad? Two PRs show assertions that held only inside one wall-clock window: a 10s stats bucket and an API Security sampling window. Both were hidden as flakiness. The fix was to accept every valid timing outcome.
Example
Use instead
Evidence:
miss(culprit #5543)absence(culprit #8348)TEST-009Several reviews found apps or tests that turned errors into valid-looking results, so assertions could not fail.
What it does: The test and its app must report an unexpected failure as a failure. Do not catch every exception and return success. Do not treat a failed command like an empty result. Do not coerce malformed input into a default value. If the app drops data that the test path needs, the test must fail.
Why is this bad? Several reviews found apps or tests that turned errors into valid-looking results, so assertions could not fail. INFRA-011 covers only shell errors that select the tested artifact.
Example
Use instead
Catch only the expected
InvocationTargetException, and return HTTP 500 for other failures.Evidence:
correction: "both endpoints swallow every exception and always return"correction: "if rc:treats exec failures like pgrep no-match, so real holders can vanish fromholders."correction: "This decoder instead discards conversion errors."correction: "theSet-Cookiefrom/session/newnever reaches the client"TEST-010Tests ignored expectations that the shared fixtures or helpers define, so some fields were never asserted.
What it does: A test must check every expected field that a shared fixture or a shared assertion helper defines. Do not skip the helper that sibling tests use.
Why is this bad? Tests ignored expectations that the shared fixtures or helpers define, so some fields were never asserted. No rule names this.
Example
Use instead
Route the test through
_assert_context_evaluation, as its siblings do.Evidence:
correction: "The imported split-feature cases includeresult.featuresexpectations for hook, exposure, and evaluation metadata"correction: "Route this test through_assert_context_evaluation, as its two siblings do."🔧 Existing rules, tuned (5)
Rules that exist, with a new case, a new exception, or better words. The Change column says which. Open the last cell of a row for the details.
META-006META-006 already requires reasons that state the real cause.
What it does: A marker contradicts its cause, or several exclusions with different causes share one vague reason. A marked test fails during setup because of invalid configuration or a missing required secret that the marker does not describe. A declaration has no reason. A declaration covers a whole file while some of its classes pass, so passing tests stop running.
Why is this bad? META-006 already requires reasons that state the real cause. Its Detect line does not catch declarations that have no reason, or file-wide declarations that hide passing classes.
Example
Evidence:
correction: "Would you consider declaring these per class with the real cause, or letting the ones that pass run?"correction: "These newmissing_featureentries have no reason."INFRA-011The rule covers hidden failures that change what is tested.
What it does: The script discards stderr (
2>/dev/null,&>/dev/null) or ignores a failure (|| true) on a command. The script counts, parses, or tests the output of that command, so an error looks like an empty result. A pipeline drops the failure of its first command becausepipefailis off, as incmd 2>/dev/null | wc -lorcmd | jq. A failed check goes silently to a fallback branch. A command runs underif !with its stderr discarded, so the failure message loses the cause. An agent setup step such asRestart-Servicefails and the script continues, or an install silently checks a file path instead of an import.Why is this bad? The rule covers hidden failures that change what is tested. Its Detect line lists only shell redirections, so it misses a provisioning script that keeps going after a failed agent restart. It also misses a file-path check that silently skips a dependency install.
Example
Evidence:
correction: "Restart-Service -Name datadogagent -Force fails with Cannot stop datadogagent service, but the script continues."correction: "Checking for themcp.pyfile feels a bit fragile: if anthropic turns it into a package,mcpsilently isn't installed and the tests just get 501s."LIFE-002Three waits were bounded in name only.
What it does: A setup or test uses a fixed sleep, polls without a deadline, or increases an arbitrary delay instead of waiting for an observable condition. A call inside a deadline loop has no timeout of its own, so it can block past the deadline. A flush timeout or wait budget is shorter than the flush interval of the library, or than other waits for the same event.
Why is this bad? Three waits were bounded in name only. In one, HTTP client calls had no timeout inside a retry loop. In another, library_interface_timeout was shorter than the Go flush period, so the last counters were lost. In the third, the app-started wait budget was tighter than the sibling waits.
Example
} return {"createdAt": "2026-11-03T00:00:00Z", "format": "SERVER", "environment": {"name": "test"}, "flags": flags} def _assert_value(test_library: APMLibrary, flag: str, value: str) -> None: deadline = time.monotonic() + 5 while True: result = test_library.ffe_evaluate(Evidence:
correction: "sends/ffe/evaluatewithout an HTTP timeout"correction: "Setlibrary_interface_timeout=15here. Go already waits 10 s, and that wait can end before its counters arrive."correction: "Worth bumping the budget or aligning it withwait_for_telemetry_configurations's loop/sleep values for consistency?"TEST-001A mock rejected a valid query because of an extra capability parameter.
What it does: When checking one protocol flag, mask that bit and accept other bits the protocol allows, unless the whole field is under test. When checking one member of a list field, such as a
tracestatevendor or anx-datadog-tagsentry, find that member. Do not require a count or an order that the protocol does not define. When checking for redaction leaks, use a distinctive marker or the relevant parsed field so unrelated payload values cannot count as leaked input. A mock server must accept a request with an extra parameter that the real service accepts. If timing selects between two valid outcomes, accept each outcome under the condition that selects it.Why is this bad? A mock rejected a valid query because of an extra capability parameter. An assertion rejected a valid timing-dependent outcome, and a flaky marker hid it. Both reject valid data.
Example
Use instead
Evidence:
absence(culprit #8143)absence(culprit #8348)TEST-001The Flag already forbids counts that the protocol does not define and raw-string comparisons.
What it does: A sampled-bit assertion requires exact flags
01. A test requireslen(tracestate) == 1or comparesx-datadog-tagsas a raw string. A redaction check searches an entire payload for a short marker such as1234. A test requires one stats bucket, although the tracer buckets stats by wall-clock time. A test compares serialized JSON strings instead of parsed values.Why is this bad? The Flag already forbids counts that the protocol does not define and raw-string comparisons. The Detect line missed stats buckets and serializer-dependent JSON strings.
Example
Use instead
Evidence:
miss(culprit #5543)correction: "json.dumpsbakes in Python's", "/": "separators."11 more changes with evidence from one PR only. They stay out of the diff. Comment
add <ID>to apply one.META-007-preversion gate cannot tell an unreleased tracer change from master.INFRA-007INFRA-005!cancelled()but was also tied to the outcome of the weblog build step.INFRA-008INFRA-013INFRA-014INFRA-015LIFE-003TEST-008TEST-005TEST-007META-007· sharpen Detect · activation-and-metadataA
-preversion gate cannot tell an unreleased tracer change from master. The reviewer asked to disable the test in the manifest and then re-enable it at the release version.Current:
Proposed:
Evidence:
correction: "first disable the affected test, then once the fix is released"INFRA-007· sharpen Detect · infrastructure-and-conventionsThe rule already asks for a retry on brittle network commands. Its Detect line names only registry pulls, so it misses a base-image build script that curls a tarball with no retry.
Current:
Proposed:
Evidence:
correction: "can you add a retry policy ?"INFRA-005· sharpen Detect · infrastructure-and-conventionsThe upload had
!cancelled()but was also tied to the outcome of the weblog build step. PARAMETRIC runs do not build a weblog, so they saved no logs. The current Detect line does not catch this.Current:
Proposed:
Evidence:
correction: "with parametric, you won't have any logs saved"INFRA-008· sharpen Flag · infrastructure-and-conventionsThe rule only covers transitive packages that the app uses directly. The unpinned dependencies of mcp are not used directly, but they can change the request bodies that VCR cassettes replay.
Current:
Proposed:
Evidence:
correction: "mcp's own deps (sse-starlette, pydantic-settings, httpx-sse, ...) aren't pinned, so a rebuild could resolve differently from what the cassettes were recorded with."INFRA-013· new rule: Load companion artifacts from the same development source. · infrastructure-and-conventionsNo rule says that a development download must also bring its paired artifacts. INFRA-011 covers hidden errors, not a companion download that is missing.
Proposed:
Proposed severity: P0. A development agent paired with a released provider is an unsupported combination, so tests can pass or fail for the wrong reason.
Evidence:
absence(culprit #7516)INFRA-014· new rule: Put backend responses in the shared mocked backend. · infrastructure-and-conventionsNo rule covers where to define mocked backend responses. A member asked for the response to be in the shared mock, and the author applied the change.
Proposed:
Proposed severity: P1. This is a convention about where shared mock behavior lives, and it does not hide a failure by itself.
Evidence:
correction: "can you add it directly in the mocked backend, rather dynamically in a test"INFRA-015· new rule: Check downstream pipelines when shared CI changes. · infrastructure-and-conventionsA change to the shared GitLab CI broke the dd-trace-php pipeline and was reverted. No rule covers downstream consumers of the shared CI.
Proposed:
Proposed severity: P1. The breakage hits other repositories' pipelines and is reverted, but it does not hide a test failure in this repository.
Evidence:
miss(culprit #8472)LIFE-003· sharpen Flag · lifecycle-and-isolationA parametric test restarted the app and read configuration telemetry that the test agent still held from the old process. LIFE-003 matches data by request id and config version, but it does not cover runtime ids after a restart.
Current:
Proposed:
Evidence:
miss(culprit #7196)TEST-008· new rule: Limit a relaxed assertion to the case that needs it. · test-effectivenessReviewers asked to keep the strict check for non-V1 payloads and the run-wide V1 guarantee for other tracers. No rule names this defect.
Proposed:
Proposed severity: P0. A relaxation that applies to every case removes coverage for the cases that still need the strict check.
Evidence:
correction: "Doesn't this change also apply to non-v1 tests? Shouldn't we still be validating the git tags are only on the first span for them?"correction: "Scoping this toGET /makes sense for PHP's pre-/infohealthcheck, but it also drops the run-wide guarantee for every other tracer that runsTest_V1PayloadByDefaultin DEFAULT."TEST-005· sharpen Detect · test-effectivenessA debugger helper tolerated a missing root timestamp only for .NET. The reviewer asked to align .NET with the shared contract. This is a library-specific branch in an assertion helper without a context.library check.
Current:
Proposed:
Evidence:
correction: "If .NET is the only SDK not adding a timestamp at the root of the payload, why don't we align .NET with the other SDKs so we include that timestamp there as well?"TEST-007· sharpen Detect · test-effectivenessNo blocking check compared the mock with the shared suite cases, because the parametric test never ran. The reviewer asked for a test-the-test check.
Current:
Proposed:
Evidence:
correction: "Add a test-the-test check that each suite case file agrees with the mock."5 defects that a rule already describes
META-006· activation-and-metadata: META-006 already requiresincomplete_test_appinstead ofmissing_featurewhen the weblog does not serve the endpoint. #8525META-006· activation-and-metadata: Aflakymarker that hides a wrong assertion is a marker that contradicts its cause, which META-006 flags. #8371INFRA-011· infrastructure-and-conventions: INFRA-011 already describes this case: a find with stderr discarded and piped to wc -l, then a fallback to the latest release. #8572TEST-002· test-effectiveness: TEST-002 already requires a positive control for absence tests and names skip.yml entries as a signal. #8144 · #8398TEST-005· test-effectiveness: The assertion changes on a context.library version check, which TEST-005 flags. #8306How to answer, and run details
How to answer each change
ok,LGTMor a thumbs up: keep the change.discardordiscard: <reason>: put the rule back as it is onmain. Outside a review thread, name the rule:discard LIFE-005.add <ID>: apply a folded change, for example one with evidence from one PR only.Not when:. The next runs read the rules.This PR only edits
.agents/rules/code-review/. It never merges by itself: a person fromsystem-tests-coreapproves it. The next monthly run publishes nothing while it is open.Coverage: test-effectiveness 12 · lifecycle-and-isolation 4 · activation-and-metadata 7 · infrastructure-and-conventions 11. 54 candidates went to another lens. 2 candidates had a quote that does not match.
Run: the workflow run in Datadog.