Skip to content

Enhance tests for assertCompleteAxiomResponse - #1302

Open
gugu8intel-i9 wants to merge 1 commit into
CodebuffAI:mainfrom
gugu8intel-i9:patch-2
Open

Enhance tests for assertCompleteAxiomResponse#1302
gugu8intel-i9 wants to merge 1 commit into
CodebuffAI:mainfrom
gugu8intel-i9:patch-2

Conversation

@gugu8intel-i9

Copy link
Copy Markdown

Bug 1: assertCompleteAxiomResponse is only tested for isPartial: true, but the error message says "partial or statusless."
Bug 2: No coverage for assertCompleteAxiomResponse with non-object inputs
Bug 3: The toThrow regex lacks an end anchor

Fixed these. Tested locally. Works on my machine and hopefully works on yours.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codebuff-team

Copy link
Copy Markdown
Contributor

Good, tightly scoped change. Splitting the original single test into separate cases (complete, partial, statusless, non-object) makes failures easier to diagnose, and adding the $ end-anchor to the toThrow regex is a real correctness improvement — without it, a stray suffix on the error message would slip through unnoticed.

The added coverage for { buckets: { totals: [] } }, { status: {} }, { status: null }, null, and undefined inputs is a legitimate improvement since the original tests only exercised isPartial: true, leaving the 'statusless' half of the error message untested — that's a fair catch.

One thing worth checking before porting: verify that assertCompleteAxiomResponse(null, ...) and assertCompleteAxiomResponse(undefined, ...) don't throw a different error (e.g. a TypeError from accessing .status on null/undefined) before your assertion even gets there — if the implementation does input.status?.isPartial, this is fine, but if it does input.status.isPartial without optional chaining, these two new tests would throw the wrong kind of error and still pass the toThrow(regex) check only if the message matches, so it's worth confirming locally that the failure mode is the intended one rather than an unrelated crash.

Small style nit: the em-dash in the test description ('statusless response — not just partials') is a little unusual for this codebase's naming conventions, but that's cosmetic only.

Overall: small, correct, in-scope, and worth porting.

@codebuff-team codebuff-team added bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree labels Sep 9, 2026
@nordicnode

Copy link
Copy Markdown

Heads up from running it: the added tests fail on the PR branch, 3 of 9. The new $ end anchor points at truncated text. The error actually thrown ends in "...statusless answer; refusing to store it." but the regex requires the message to end at "answer", so every new throws-case fails:

Expected pattern: /^hour 12: Axiom returned a partial or statusless answer$/ Received message: "hour 12: Axiom returned a partial or statusless answer; refusing to store it."

Repro: cd common && bun test src/util/tests/axiom-complete-response.test.ts. Deterministic on both the pinned bun 1.3.14 and 1.4.0, so "works on my machine" doesn't seem to hold for this commit. The merge-base file passes 6/6, so the anchor is the only breakage.

Direction of the change is right though. Anchoring the full message, e.g. /^hour 12: Axiom returned a partial or statusless answer; refusing to store it.$/ (note the escaped dot), turns it green 9/9 on both runtimes, which I checked locally. That's six copies of the regex in the diff, so a single shared const might be cleaner for the same coverage.

Also, in case it saves a maintainer time: the TypeError worry from the review above isn't a thing. The implementation early-returns on non-objects before touching .status, so null and undefined throw the intended refusal error, just with a message that doesn't match the pattern.

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

Labels

bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants