Skip to content

fix: check on traits and traits.context (#4682) - #4698

Merged
koladilip merged 1 commit into
developfrom
external/ThabetIbrahim/fix-identify-payload
Oct 6, 2025
Merged

koladilip merged 1 commit into
developfrom
external/ThabetIbrahim/fix-identify-payload

Conversation

@lvrach

@lvrach lvrach commented Oct 6, 2025

Copy link
Copy Markdown
Member
  • fix: check on traits and traits.context

  • prioritize message.context.traits

What are the changes introduced in this PR?

Write a brief explainer on your code changes.

What is the related Linear task?

Resolves INT-XXX

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

N/A

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

N/A

Any technical or performance related pointers to consider with the change?

N/A

@coderabbitai review


Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • Is the PR limited to 10 file changes?

  • Is the PR limited to one linear task?

  • Are relevant unit and component test-cases added in new readability format?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

* fix: check on traits and traits.context

* prioritize message.context.traits
@lvrach
lvrach requested a review from a team as a code owner October 6, 2025 10:55
@coderabbitai

coderabbitai Bot commented Oct 6, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of trait extraction in Identify events with smarter fallbacks.
    • Sends company data only when a valid company ID is present, avoiding partial or invalid objects.
    • Cleans payloads by removing undefined/null values from traits and metadata.
    • Ensures metadata reflects the final, processed traits for consistency across requests.

Walkthrough

Refactors identify payload construction in src/cdk/v2/destinations/userpilot/procWorkflow.yaml to introduce a unified userTraits source (from message.context.traits or message.traits), derive companyTraits from userTraits.company, update company inclusion checks to use companyTraits.id, and base metadata transformation on the sanitized userTraits.

Changes

Cohort / File(s) Summary of Changes
Userpilot identify transformation
src/cdk/v2/destinations/userpilot/procWorkflow.yaml
- Create userTraits as fallback of message.context.traits and message.traits
- Derive companyTraits from userTraits.company
- Use companyTraits.id to decide sending company object, else null
- Replace trait processing input with userTraits
- Keep metadata transformation based on sanitized userTraits

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Src as Event Source
  participant Proc as Userpilot ProcWorkflow
  participant UP as Userpilot API

  Src->>Proc: identify(message)
  note over Proc: Build userTraits = context.traits || traits
  Proc->>Proc: Derive companyTraits = userTraits.company
  alt companyTraits.id present
    Proc->>Proc: Include company in payload
  else
    Proc->>Proc: Set company = null
  end
  Proc->>Proc: Sanitize userTraits for metadata
  Proc->>UP: POST identify payload
  UP-->>Proc: Response
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggestions: Verify edge cases where traits are arrays or non-objects; add unit tests for fallback resolution and company nulling.

Possibly related PRs

Suggested reviewers

  • vinayteki95
  • koladilip

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title “fix: check on traits and traits.context (#4682)” is overly generic and includes an unnecessary reference to the issue number, and it does not clearly describe the core change—namely the update to the identifyPayload fallback logic and derivation of companyTraits. This lack of specificity makes it difficult for reviewers to quickly grasp the primary intent of the pull request. As a result, it does not meet the criteria for a concise and descriptive title. Please revise the title to succinctly reflect the primary change without noise, for example “fix(identifyPayload): prioritize message.context.traits and derive companyTraits from userTraits.”
Description Check ⚠️ Warning The description still contains the original template placeholders and does not include an actual summary of the code changes under “What are the changes introduced in this PR?” or expanded objectives in the subsequent sections, making it impossible to understand what was modified and why. Key information such as a brief explainer of the changes, details on dependent work, and confirmation of testing or documentation updates is missing. This means the required template structure has not been properly filled out. Please fill in each section of the template with concrete details: describe the changes, link the related Linear task, outline objectives and any impacts, and complete the developer checklist to ensure reviewers have all necessary context.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch external/ThabetIbrahim/fix-identify-payload

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49ee4e0 and 6ffc4c5.

📒 Files selected for processing (1)
  • src/cdk/v2/destinations/userpilot/procWorkflow.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Code Coverage
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: UT Tests
  • GitHub Check: test_and_publish

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Oct 6, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.80%. Comparing base (892ebd7) to head (6ffc4c5).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop    #4698    +/-   ##
=========================================
  Coverage    91.79%   91.80%            
=========================================
  Files          645      650     +5     
  Lines        34086    34486   +400     
  Branches      8050     8098    +48     
=========================================
+ Hits         31290    31660   +370     
- Misses        2544     2574    +30     
  Partials       252      252            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2025

Copy link
Copy Markdown

@koladilip
koladilip merged commit b8d180a into develop Oct 6, 2025
@koladilip
koladilip deleted the external/ThabetIbrahim/fix-identify-payload branch October 6, 2025 11:38
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.

4 participants