Repository navigation
fix(mentorWriteRecommendations): Pin CSV columns so the feedback column is never dropped - #59
Merged
tylermenezes merged 1 commit intoSep 18, 2026
Conversation
…mn is never dropped
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detail bug report: View on Detail
Bug
mentorWriteRecommendationsassembles one CSV record per mentor and serializes them withcsv-stringifyusingheader: trueand no explicitcolumns. With that option combination,csv-stringify@6.4.6derives the column set from the first record only. TheWhat Students Had to Saykey is conditionally present (added only when a mentor has qualifying student feedback across their CodeDay events), so record shapes are heterogeneous. Whenprisma.mentor.findMany(which has noorderBy) returns a feedback-less mentor first, theWhat Students Had to Saycolumn 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-linepromptcell. The GPT-writtenresult(the LinkedIn recommendation) is unaffected since it consumes feedback viapromptbefore serialization.Fix
Pin an explicit, ordered
columnslist so the header no longer depends on the first record's keys. Extracted the serialization into a small pure helperbuildRecommendationsCsv(recommendations)insrc/activities/tasks/mentorWriteRecommendations.tsthat callsstringify(recommendations, { header: true, columns: CSV_COLUMNS }), and the task now calls it. This leavesmentorInformationand the GPTpromptuntouched, 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/projectParticipationsinsrc/automation/tasks/syncAlumniInteractions.test.ts).Testing
src/activities/tasks/mentorWriteRecommendations.test.ts(hand-rolled assert style matchingsyncAlumniInteractions.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) viacsv-parseround-trip, checks multi-line/comma-laden feedback round-trips intact, and guards the unconditional columns (incl. comma-bearingStudents Mentoredand theresultdeliverable).npx tsc --skipLibCheck --noEmit) andnpm run build(the CI-equivalent compile) pass.prisma db push, and ran the real task against seeded data — a feedback-less mentor inserted first soprisma.mentor.findManyreturns it first, and a with-feedback mentor second. OpenAI was mocked via TypeDI and the SlackWebClient.files.uploadHTTP dispatch was capture-patched so no network or real key was needed. The uploaded CSV's header containedWhat 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 GPTresultcells 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.npx eslintfails with a0: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.1incompatibility, not caused by this change. ESLint is not part of CI here (the CircleCI job only runs the Docker build, which runstsc), and typecheck/build both pass.Automatic Fixes PRs can be configured here.