Skip to content

refactor(api-proxy): deduplicate null tool_call type normalization#3272

Merged
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-null-tool-call-logic
May 16, 2026
Merged

refactor(api-proxy): deduplicate null tool_call type normalization#3272
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-null-tool-call-logic

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

copilot.js contained a near-identical copy of sanitizeNullToolCallTypes from body-transform.js (the shared utilities module), meaning a bug fix in one wouldn't propagate to the other.

Changes

  • providers/copilot.js: Removes normalizeNullTypeToolCalls entirely. Imports sanitizeNullToolCallTypes from ../body-transform and replaces the body transform reference with a one-line wrapper that bridges the return-type difference:

    (body) => { const result = sanitizeNullToolCallTypes(body); return result ? result.body : null; }

    Also removes normalizeNullTypeToolCalls from the _testing export.

  • server.auth.test.js: Migrates the normalizeNullTypeToolCalls describe block to test sanitizeNullToolCallTypes directly (imported from body-transform), updating assertions to match its { body, normalizedCount, droppedCount } return shape.

Copilot AI changed the title [WIP] Fix duplicate null-tool-call normalization logic refactor(api-proxy): deduplicate null tool_call type normalization May 16, 2026
Copilot finished work on behalf of lpcox May 16, 2026 22:09
Copilot AI requested a review from lpcox May 16, 2026 22:09
@lpcox lpcox marked this pull request as ready for review May 16, 2026 22:22
@lpcox lpcox requested a review from Mossaka as a code owner May 16, 2026 22:22
Copilot AI review requested due to automatic review settings May 16, 2026 22:22
@github-actions
Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Status
GitHub MCP connectivity ❌ (401 Bad credentials)
GitHub.com HTTP connectivity ⚠️ (pre-step data unavailable)
File write/read ✅ (smoke-test-copilot-25974231160.txt exists)

Overall: FAIL — GitHub MCP auth failed; pre-step template variables were not expanded.

Author/assignees could not be fetched due to MCP auth error.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results:

  • ❌ GitHub API: HTTP 401 authentication error
  • ✅ Playwright: Title contains 'GitHub'
  • ✅ File verify: smoke-test file present

Status: FAIL (2/3 tests passed)

💥 [THE END] — Illustrated by Smoke Claude

@github-actions github-actions Bot mentioned this pull request May 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP connectivity ❌ (401 — MCP tools unauthenticated in this environment)
GitHub.com HTTP ⚠️ Template vars not resolved (${{ steps.smoke-data.outputs.SMOKE_HTTP_CODE }})
File write/read ⚠️ Template vars not resolved (${{ steps.smoke-data.outputs.SMOKE_FILE_PATH }})
BYOK inference (agent→api-proxy→api.githubcopilot.com)

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com.

Overall: PARTIAL — BYOK inference path confirmed working; pre-step template variables were not substituted before agent invocation.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Codex

PRs: fix: remove unused exports from public API surface (batch 2); refactor: split src/host-env.ts into focused modules
✅ GitHub PR review, Playwright, file/bash, build
❌ safeinputs-gh missing; Tavily tools unavailable; discussion query tool missing
Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the API proxy’s Copilot provider to remove a duplicated “null tool_call type” normalizer and instead reuse the shared sanitizeNullToolCallTypes utility from body-transform.js, with corresponding test updates.

Changes:

  • providers/copilot.js: Removes the local normalizeNullTypeToolCalls implementation and wires sanitizeNullToolCallTypes into the Copilot adapter’s body transform via a wrapper that adapts return types.
  • server.auth.test.js: Updates the former normalizer tests to target sanitizeNullToolCallTypes and its { body, normalizedCount, droppedCount } return shape.
Show a summary per file
File Description
containers/api-proxy/providers/copilot.js Deduplicates Copilot’s tool_call type normalization by delegating to sanitizeNullToolCallTypes.
containers/api-proxy/server.auth.test.js Migrates tests from the removed Copilot-specific normalizer to the shared sanitizer.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment on lines 193 to 196
const bodyTransform = composeBodyTransforms(
deps.bodyTransform || null,
normalizeNullTypeToolCalls
(body) => { const result = sanitizeNullToolCallTypes(body); return result ? result.body : null; }
);
Comment on lines 174 to 195
@@ -188,9 +189,9 @@ describe('normalizeNullTypeToolCalls', () => {
],
}));

const transformed = normalizeNullTypeToolCalls(input);
expect(transformed).not.toBeNull();
const parsed = JSON.parse(transformed.toString('utf8'));
const result = sanitizeNullToolCallTypes(input);
expect(result).not.toBeNull();
const parsed = JSON.parse(result.body.toString('utf8'));
expect(parsed.messages[0].tool_calls[0].type).toBe('function');
@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color passed ✅ PASS
Go env passed ✅ PASS
Go uuid passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx passed ✅ PASS
Node.js execa passed ✅ PASS
Node.js p-limit passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Note: Java required mvn -Dmaven.repo.local=/tmp/... workaround as ~/.m2 was owned by root in this environment.

Generated by Build Test Suite for issue #3272 · ● 4.2M ·

@github-actions
Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.15.0 v20.20.2
Go go1.22.12 go1.22.12

Result: FAILED — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

Gemini Smoke Test: Running...

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results — FAIL

Check Result
Redis PING ❌ Timeout
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Not attempted (pg unreachable)

Overall: FAILhost.docker.internal service containers are not reachable from this environment.

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox merged commit 777c0b2 into main May 16, 2026
71 of 74 checks passed
@lpcox lpcox deleted the copilot/fix-duplicate-null-tool-call-logic branch May 16, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Duplicate Code] Duplicate null-tool-call normalization logic in copilot.js and body-transform.js

3 participants