fix(RequestService): route alert commands to v1 API for ICE vehicles v3 for EV/Hybrid#498
Open
BigThunderSR wants to merge 2 commits intomasterfrom
Open
fix(RequestService): route alert commands to v1 API for ICE vehicles v3 for EV/Hybrid#498BigThunderSR wants to merge 2 commits intomasterfrom
BigThunderSR wants to merge 2 commits intomasterfrom
Conversation
… v3 for EV/Hybrid
- Add intelligent API version routing for alert/flash commands based on engine type
- Detect vehicle engine type (ICE vs EV/Hybrid) from diagnostics data
- ICE vehicles use v1 API endpoint (/api/v1/account/vehicles/{VIN}/commands/alert)
- EV/Hybrid vehicles use v3 API endpoint (/veh/cmd/v3/alert/{VIN})
- Implement disk-based caching of engine type to minimize API calls
- Cache persists across sessions in vehicle_type_{VIN}.json
- Add vehicle_type_*.json to .gitignore and .npmignore
Fixes issue where alert/flashLights commands were failing with 400 Bad Request
for ICE vehicles due to v3 API incompatibility.
Related commands affected:
- alert()
- flashLights()
- cancelAlert()
- stopLights()
Pull Request Test Coverage Report for Build 18390876940Details
💛 - Coveralls |
…uting - Add 12 new unit tests covering: - ENGINE_TYPE detection from diagnostics (ICE and EV) - Fuel level fallback detection (ICE) - Battery diagnostics fallback detection (EV) - Memory caching behavior - Disk caching behavior - API endpoint routing for both vehicle types - v1 API usage for ICE vehicles - v3 API usage for EV vehicles - Update functional test to handle both v1 and v3 API response structures - Add beforeEach hook to clear cache between tests - Mock disk I/O operations to avoid file system side effects Coverage improved: - Statements: 88.74% - Branches: 80.23% - Functions: 94.39% - Lines: 88.52%
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.
Fix alert commands failing with 400 Bad Request on ICE vehicles
Problem
Alert and flash light commands (
alert(),flashLights(),cancelAlert(),stopLights()) fail with HTTP 400 errors on Internal Combustion Engine (ICE) vehicles. The v3 API endpoint (/veh/cmd/v3/alert/{VIN}) does not support these commands for ICE vehicles.Solution
Implement automatic API version routing based on vehicle engine type:
/api/v1/account/vehicles/{VIN}/commands/alert)/veh/cmd/v3/alert/{VIN})Implementation
Engine Type Detection
ENGINE_TYPEfrom diagnostics APIdiagnosticElementsarrayCaching
vehicle_type_{VIN}.jsonto minimize diagnostics API calls across sessions.gitignoreand.npmignoreMethods
isICEVehicle(): Determines engine type with cachingloadVehicleTypeFromDisk(): Reads cached type from disksaveVehicleTypeToDisk(): Persists type to diskgetVehicleTypeCachePath(): Returns cache file pathTesting
Unit Tests (12 new tests)
Functional Tests
Coverage
Files Changed
src/RequestService.ts(+178 lines): Detection and routing logictest/unit/RequestService.test.ts(+195 lines): Comprehensive test coveragetest/functional/OnStarJs.test.ts(+17 lines): Handle both API versions.gitignore,.npmignore(+3 lines each): Exclude cache files