fix(record): remove Number() coercion in reload and destroyRecord to support string ids#246
Merged
michaeljymsgutierrez merged 2 commits intoJul 2, 2026
Conversation
…support string ids
…support string ids
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Description
record.reload()andrecord.destroyRecord()were callingNumber()on the record ID before passing it to the internal_request()method. For numeric IDs this was harmless, but for string IDs likeJO-26181S4VPU65,Number()returnsNaN, causing the request URL to become/api/v1/resource/NaNinstead of/api/v1/resource/JO-26181S4VPU65.This fix removes the
Number()coercion from both_reloadRecordand_deleteRecord, passing the ID as-is - consistent with how_saveRecordandfindRecordalready handle IDs. The internal_request()method already supports both number and string IDs viaisNumber(resourceId) || isString(resourceId).Github Issue: N/A
Changes
packages/src/lib/api-resource-manager.js- removedNumber()coercion from_reloadRecord(line 740) and_deleteRecord(line 718); both now passgetProperty(currentRecord, 'id')directly asresourceIdpackages/tests/units/record.js- added two new tests: "Verify reload with string collection record id" and "Verify destroyRecord with string collection record id"packages/tests/mirage/index.js- updatedDELETE /addresses/:idhandler to echo back a record with the matching string ID when a non-numeric ID is provided, enabling proper unload assertion in the destroyRecord testpackages/dist/arm-js-library.js- rebuilt distribution file reflecting the source fixScreenshots/Images
N/A - no UI changes.
How Has This Been Tested?
reloadanddestroyRecordwith string IDs - both passyarn test)Number()orparseIntcoercions remain;_saveRecord,findRecord,peekRecord, and_getCollectionRecordall already handle string IDs correctlyChecklist
Reviewer Guidance
api-resource-manager.js(theNumber()wrappers in_reloadRecordand_deleteRecord)_saveRecordwas already correct and did not need changes - it usesuuidValidate()to distinguish new records (UUID) from existing ones (any non-UUID ID), then passes the ID as-isunloadRecordcan find and remove the right record by hashId