Skip to content

fix: generate UUID fallback for missing x-request-id header in edge functions - #5

Draft
TrainTravel with Copilot wants to merge 2 commits into
feat/ai-request-tracingfrom
copilot/sub-pr-1-another-one
Draft

fix: generate UUID fallback for missing x-request-id header in edge functions#5
TrainTravel with Copilot wants to merge 2 commits into
feat/ai-request-tracingfrom
copilot/sub-pr-1-another-one

Conversation

Copilot AI commented Mar 2, 2026

Copy link
Copy Markdown

Fixed "no-id" static fallback for x-request-id in french-chat and reflection edge functions, which collapsed all header-less requests into the same log identifier, making traces unattributable.

Changes

  • requestId fallback — replaced ?? "no-id" with ?? crypto.randomUUID() in both functions, matching the pattern already used in french-feedback
  • Scope fix — moved requestId declaration outside the try block so catch handlers use the same unique ID rather than a stale hardcoded [no-id]
// Before
try {
  const requestId = req.headers.get("x-request-id") ?? "no-id";
  ...
} catch (error) {
  console.error(`[no-id] Error in french-chat function:`, error); // always "no-id"
}

// After
const requestId = req.headers.get("x-request-id") ?? crypto.randomUUID();
try {
  ...
} catch (error) {
  console.error(`[${requestId}] Error in french-chat function:`, error); // unique per request
}

Affected functions: french-chat, reflection.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: TrainTravel <25241752+TrainTravel@users.noreply.github.com>
Copilot AI changed the title [WIP] Update AI request tracing and client logging based on feedback fix: generate UUID fallback for missing x-request-id header in edge functions Mar 2, 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