Skip to content

fix: validate LLM work experience squash result#4059

Merged
skwowet merged 1 commit intomainfrom
bugfix/member-enrichment-payload
Apr 27, 2026
Merged

fix: validate LLM work experience squash result#4059
skwowet merged 1 commit intomainfrom
bugfix/member-enrichment-payload

Conversation

@skwowet
Copy link
Copy Markdown
Collaborator

@skwowet skwowet commented Apr 27, 2026

Summary

  • Ensure LLM work experience squashing returns a top-level JSON array.
  • Throw on invalid response shape so Temporal retries instead of failing later with .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 squashWorkExperiencesWithLLM to verify res.result is 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.

…periencesWithLLM func

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
@skwowet skwowet self-assigned this Apr 27, 2026
Copilot AI review requested due to automatic review settings April 27, 2026 10:54
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 function later.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/apps/members_enrichment_worker/src/activities/llm.ts
@skwowet skwowet merged commit c646de0 into main Apr 27, 2026
22 checks passed
@skwowet skwowet deleted the bugfix/member-enrichment-payload branch April 27, 2026 11:19
skwowet added a commit that referenced this pull request Apr 28, 2026
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
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