Draft
Conversation
Collaborator
mazar-farran
commented
Nov 20, 2025
- Add a link to the ticket in the PR title or add a description of work in the PR title
- dashcam firmware was loaded on a device and successfully runs
For some reason I can run the tests individually but not together
This still needs more testing. If possible this logic needs to be rewritten
Collaborator
Author
mazar-farran
commented
Dec 2, 2025
punov
approved these changes
Dec 2, 2025
Collaborator
Author
|
Posponing this until after high priority feature requests are resolved |
Contributor
Greptile OverviewGreptile SummaryRefactored LTE upload service with improved type safety and testability by extracting types to a dedicated file, replacing string-based state management with typed interfaces, and separating error handling logic into dedicated functions. Tests were rewritten to be more isolated and comprehensive, with better mocking strategies. Key Changes:
Issues Found:
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| tests/services/getFrameKmService.test.ts | Refactored tests to use new storage API, added tests for error scenarios, data saver mode, and commit failures |
| src/index.ts | Updated initializeLTEStorage to pass database instance explicitly |
| src/services/getFrameKmsService.ts | Major refactor with typed state management, extracted error handlers, removed old framekm cleanup logic, and fixed database initialization - contains potential null handling bug |
| src/types/getFrameKms.ts | New type definitions file for frame km states, error classes, and package types |
Sequence Diagram
sequenceDiagram
participant Service as GetFrameKmsService
participant Storage as FrameKmStorage
participant API as Backend API
participant S3 as S3 Storage
Service->>Storage: checkForNewFrameKms()
Storage-->>Service: Return framekm list
Service->>Storage: getFrameKmItem(framekm)
Storage-->>Service: status: INIT
Service->>API: postFrameKmRequest(framekm)
API-->>Service: {id, type, signedContentUrls, frameIndicesToUpload}
Service->>Storage: setFrameKmItem(framekm, REQUEST_SUCCESS)
alt Data Saver with frames
Service->>Service: packCustomFrameKm()
else Data Saver without frames
Service->>Storage: setFrameKmItem(framekm, UPLOAD_SUCCESS, multiparts:[])
end
Service->>Storage: getFrameKmItem(framekm)
Storage-->>Service: status: REQUEST_SUCCESS
loop For each signed URL
Service->>S3: Upload framekm part
S3-->>Service: ETag
end
Service->>Storage: setFrameKmItem(framekm, UPLOAD_SUCCESS)
Service->>Storage: getFrameKmItem(framekm)
Storage-->>Service: status: UPLOAD_SUCCESS
Service->>API: commitFrameKm(id, multiparts)
API-->>Service: Success
Service->>Storage: setFrameKmItem(framekm, COMMIT_SUCCESS)
Service->>Service: cleanup(framekm)
Comment on lines
+133
to
+136
| async getFrameKmItem<T extends FrameKmItem>(key: string) { | ||
| const value = await super.getItem(key); | ||
| return JSON.parse(value) as T; | ||
| } |
Contributor
There was a problem hiding this comment.
JSON.parse(value) will throw "Unexpected token u in JSON" when value is undefined (when key doesn't exist).
Suggested change
| async getFrameKmItem<T extends FrameKmItem>(key: string) { | |
| const value = await super.getItem(key); | |
| return JSON.parse(value) as T; | |
| } | |
| async getFrameKmItem<T extends FrameKmItem>(key: string) { | |
| const value = await super.getItem(key); | |
| if (!value) { | |
| throw new Error(`FrameKm item not found: ${key}`); | |
| } | |
| return JSON.parse(value) as T; | |
| } |
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.
