Skip to content

fix(examples): consistent CSV schema in survey_agent#1435

Merged
u9g merged 1 commit into
mainfrom
fix/survey-agent-csv-schema
May 12, 2026
Merged

fix(examples): consistent CSV schema in survey_agent#1435
u9g merged 1 commit into
mainfrom
fix/survey-agent-csv-schema

Conversation

@u9g
Copy link
Copy Markdown
Contributor

@u9g u9g commented May 8, 2026

Description

Fix two correctness bugs in survey_agent.ts: disqualify and success rows used different column sets under one header, and access + appendFile raced on header creation.

Changes Made

  • Pin layout to a fixed CSV_COLUMNS tuple; missing keys become empty cells.
  • Replace access + two appendFiles with one open('a') + stat() + single appendFile.
  • Drop redundant empty-string branch in toCsvValue.
  • Populate name on the success path from userData.candidateName.

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass
  • Make sure both `restaurant_agent.ts` and `realtime_agent.ts` work properly (for major changes)

Additional Notes


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

Both write paths in writeCsvRow used Object.keys(data) for the row
layout, but only the first call wrote a header — so disqualify rows
(2 cols) and success rows (6 cols) ended up under whichever header
won the race. Pin the schema to a fixed CSV_COLUMNS tuple, write rows
in that order, and fill missing keys as empty.

Also replace the access()+appendFile TOCTOU pattern with a single
open('a') + stat() so the header decision and the write happen on
the same handle, and combine header+row into one appendFile call.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 8, 2026

⚠️ No Changeset found

Latest commit: 75e1bb9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@u9g u9g enabled auto-merge (squash) May 8, 2026 18:52
@u9g u9g merged commit c9e96d5 into main May 12, 2026
9 checks passed
@u9g u9g deleted the fix/survey-agent-csv-schema branch May 12, 2026 02:37
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