Repository navigation
fix: remove hard check for timestamp for airship - #4214
Conversation
Summary by CodeRabbit
WalkthroughThis pull request updates the functionality of the Changes
Sequence Diagram(s)sequenceDiagram
participant T as Test Suite
participant U as convertToAirshipTimestamp
participant M as moment.utc
T->>U: Call with "2025-03-27 16:00:48 +0100"
U->>M: Attempt conversion of input string
M-->>U: Return formatted timestamp ("2025-03-27T16:00:48Z")
U-->>T: Return formatted timestamp
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (10)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4214 +/- ##
===========================================
- Coverage 91.06% 91.06% -0.01%
===========================================
Files 635 635
Lines 33172 33175 +3
Branches 7836 7837 +1
===========================================
+ Hits 30208 30210 +2
- Misses 2716 2748 +32
+ Partials 248 217 -31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
src/v0/destinations/airship/utils.test.ts (1)
399-475: 💡 Verification agent🧩 Analysis chain
Verify that tests still properly handle error cases.
There are pipeline failures indicating that expected exceptions are not being thrown for invalid timestamps. This suggests the simplified validation check might be affecting error handling.
🏁 Script executed:
#!/bin/bash # Check if the test failures are directly related to the code changes # First, let's check the specific test case for invalid timestamps rg -A 5 -B 5 "should throw error when timestamp is not supported" src/v0/destinations/airship/utils.test.ts # Then check the corresponding implementation in utils.ts rg -A 5 -B 5 "timestamp is not supported" src/v0/destinations/airship/utils.ts # Finally, check the previous implementation of the validation condition git show HEAD~1:src/v0/destinations/airship/utils.ts | rg -A 3 -B 3 "Check if the input is a valid date string"Length of output: 1913
Action Required: Resolve Error Handling Mismatch in Timestamp Conversion
The pipeline failures indicate that when an invalid timestamp like
"abcd"is provided, the error message ends up as"timestamp is not supported: NaN"instead of the expected"timestamp is not supported: abcd". This appears to stem from converting the input string to a number before throwing the error.Suggestions:
- Preserve the Original Input: Store the original timestamp (e.g., in a variable like
originalTimestamp) before converting it. Then use this original value in the error message.- Review the Conversion Order: Consider adjusting the order of operations so that the string validation using
moment.utc(timestamp, moment.ISO_8601, true)does not inadvertently mask the intended error handling.- Double-check Similar Cases: Verify that other error scenarios (such as the incorrect epoch second case) produce error messages that include the initial input rather than its converted form.
For example, updating the error branch as follows could address the issue:
- timestamp = Number(timestamp); // Convert string to number + const originalTimestamp = timestamp; + timestamp = Number(timestamp); // Convert string to number ... - throw new InstrumentationError(`timestamp is not supported: ${timestamp}`); + throw new InstrumentationError(`timestamp is not supported: ${originalTimestamp}`);Please adjust the error handling accordingly so that the tests correctly catch and match the expected exception messages.
🧰 Tools
🪛 GitHub Actions: Allure Test Reporter
[error] 468-468: Test failed: Expected substring 'timestamp is not supported: abcd' but received function did not throw.
🧹 Nitpick comments (1)
src/v0/destinations/airship/utils.ts (1)
57-88: Consider refactoring to improve readability and consistency.The function has multiple code paths and validation conditions. The change to simplify the string validation makes sense, but consider refactoring to make the validation logic more consistent between string and number inputs.
export const convertToAirshipTimestamp = (timeValue: string | number): string => { let millis; let timestamp = timeValue; // Check if the input is a string containing a numeric timestamp if (typeof timestamp === 'string' && isNumeric(timestamp)) { timestamp = Number(timestamp); // Convert string to number } // Check if the input is a valid date string if (typeof timestamp === 'string') { + const parsedDate = moment.utc(timestamp); + if (!parsedDate.isValid()) { + throw new InstrumentationError(`timestamp is not supported: ${timestamp}`); + } - return moment.utc(timestamp).format(AIRSHIP_TIMESTAMP_FORMAT); + return parsedDate.format(AIRSHIP_TIMESTAMP_FORMAT); } // If it's a number, handle different timestamp formats if (typeof timestamp === 'number') { const { length } = timestamp.toString(); if (length === 10) { millis = timestamp * 1000; // Convert seconds to milliseconds } else if (length === 13) { millis = timestamp; // Already in milliseconds } else if (length === 16) { millis = Math.floor(timestamp / 1000); // Convert microseconds to milliseconds } else { throw new InstrumentationError(`timestamp is not supported: ${timestamp}`); } + const parsedDate = moment.utc(millis); + if (!parsedDate.isValid()) { + throw new InstrumentationError(`timestamp is not supported: ${timestamp}`); + } - return moment.utc(millis).format(AIRSHIP_TIMESTAMP_FORMAT); + return parsedDate.format(AIRSHIP_TIMESTAMP_FORMAT); } throw new InstrumentationError(`timestamp is not supported: ${timestamp}`); };
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/v0/destinations/airship/utils.test.ts(1 hunks)src/v0/destinations/airship/utils.ts(1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/v0/destinations/airship/utils.ts (1)
src/v0/destinations/airship/transform.js (1)
timestamp(139-139)
🪛 GitHub Actions: Allure Test Reporter
src/v0/destinations/airship/utils.test.ts
[error] 57-57: Test failed: Expected substring 'timestamp is not supported: abcd' but received function did not throw.
[error] 468-468: Test failed: Expected substring 'timestamp is not supported: abcd' but received function did not throw.
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Build User 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 Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: ingestion-service-test
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
src/v0/destinations/airship/utils.test.ts (1)
452-456: Test case addition looks appropriate.The new test case checks for handling date-time strings with timezone offsets, which aligns with the changes made to the validation logic in the utils.ts file. This test helps verify that removing the strict ISO 8601 validation doesn't break functionality for valid date-time strings in different formats.
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|



What are the changes introduced in this PR?
Remove ISO_8601 timestamp format check when converting to airship defined timestamp
What is the related Linear task?
Resolves INT-3461
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.