Skip to content

fix(mentorWriteRecommendations): Pin CSV columns so the feedback column is never dropped - #59

Merged
tylermenezes merged 1 commit into
mainfrom
detail/bug-fix/fix-mentorwriterecommendations-pin-csv-columns-so-b658f0
Sep 18, 2026
Merged

tylermenezes merged 1 commit into
mainfrom
detail/bug-fix/fix-mentorwriterecommendations-pin-csv-columns-so-b658f0

Conversation

@detail-app

@detail-app detail-app Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Bug

mentorWriteRecommendations assembles one CSV record per mentor and serializes them with csv-stringify using header: true and no explicit columns. With that option combination, csv-stringify@6.4.6 derives the column set from the first record only. The What Students Had to Say key is conditionally present (added only when a mentor has qualifying student feedback across their CodeDay events), so record shapes are heterogeneous. When prisma.mentor.findMany (which has no orderBy) returns a feedback-less mentor first, the What Students Had to Say column is silently dropped from the header and every later mentor's feedback cell is dropped too, with the text only recoverable by fishing it back out of the multi-line prompt cell. The GPT-written result (the LinkedIn recommendation) is unaffected since it consumes feedback via prompt before serialization.

Fix

Pin an explicit, ordered columns list so the header no longer depends on the first record's keys. Extracted the serialization into a small pure helper buildRecommendationsCsv(recommendations) in src/activities/tasks/mentorWriteRecommendations.ts that calls stringify(recommendations, { header: true, columns: CSV_COLUMNS }), and the task now calls it. This leaves mentorInformation and the GPT prompt untouched, so recommendation wording is not perturbed (the conditional spread that keeps the prompt clean for feedback-less mentors is preserved). The extraction mirrors the repo's existing testable-seam pattern (buildDiffPlan/projectParticipations in src/automation/tasks/syncAlumniInteractions.test.ts).

Testing

  • New committed unit test src/activities/tasks/mentorWriteRecommendations.test.ts (hand-rolled assert style matching syncAlumniInteractions.test.ts): pins the header even when the first record lacks the feedback key, verifies a later mentor's feedback lands in a dedicated header-addressable cell (and a feedback-less mentor gets an empty cell) via csv-parse round-trip, checks multi-line/comma-laden feedback round-trips intact, and guards the unconditional columns (incl. comma-bearing Students Mentored and the result deliverable).
  • Typecheck (npx tsc --skipLibCheck --noEmit) and npm run build (the CI-equivalent compile) pass.
  • End-to-end verification (not versioned): started Postgres in a Docker container, applied the schema with prisma db push, and ran the real task against seeded data — a feedback-less mentor inserted first so prisma.mentor.findMany returns it first, and a with-feedback mentor second. OpenAI was mocked via TypeDI and the Slack WebClient.files.upload HTTP dispatch was capture-patched so no network or real key was needed. The uploaded CSV's header contained What Students Had to Say, the with-feedback mentor's dedicated cell equaled the reformatted feedback blob, the feedback-less mentor's cell was empty, the GPT result cells populated for both, and the captured GPT prompts confirmed the feedback section appears only for the with-feedback mentor (prompt input unchanged). The harness and the throwaway Postgres container were cleaned up after.
  • Lint could not be run: npx eslint fails with a 0:0 Parsing error: DeprecationError: 'originalKeywordKind' on both changed files and identically on an untouched control file (src/automation/tasks/syncAlumniInteractions.test.ts), so this is a pre-existing TypeScript 5.2.2-vs-@typescript-eslint/parser@3.10.1 incompatibility, not caused by this change. ESLint is not part of CI here (the CircleCI job only runs the Docker build, which runs tsc), and typecheck/build both pass.

Automatic Fixes PRs can be configured here.

@detail-app
detail-app Bot requested a review from tylermenezes September 18, 2026 02:54
@tylermenezes
tylermenezes merged commit 985bff0 into main Sep 18, 2026
1 check passed
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.

1 participant