fix: validate LLM work experience squash result#4059
Conversation
…periencesWithLLM func Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
1 similar comment
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
This PR hardens the members enrichment worker’s LLM work-experience “squash” activity by ensuring the LLM response is a top-level JSON array and failing fast when it isn’t, so Temporal can retry instead of encountering downstream runtime errors.
Changes:
- Fix the prompt’s JSON output example formatting (missing comma) and tighten the output instruction to require a JSON array.
- Validate the LLM response shape (
Array.isArray) and throw a retryable error if invalid, preventing.forEach is not a functionlater.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Summary
.forEach is not a function.Note
Medium Risk
Low-complexity change, but it alters failure behavior in the enrichment workflow by throwing earlier and triggering Temporal retries when the LLM returns malformed JSON.
Overview
Updates the work-experience squashing prompt to explicitly require a top-level JSON array response.
Adds a runtime shape check in
squashWorkExperiencesWithLLMto verifyres.resultis an array, logging a warning and throwing an error when invalid to avoid downstream.forEach-style crashes and let Temporal retry.Reviewed by Cursor Bugbot for commit 64f50bc. Bugbot is set up for automated code reviews on this repo. Configure here.