fix(script): .response.cookies.toObject() should return an object - #10307
Open
ihexxa wants to merge 1 commit into
Open
fix(script): .response.cookies.toObject() should return an object#10307ihexxa wants to merge 1 commit into
ihexxa wants to merge 1 commit into
Conversation
✅ Circular References ReportGenerated at: 2026-08-04T07:51:27.219Z Summary
Click to view all circular references in PR (9)Click to view all circular references in base branch (9)Analysis✅ No Change: This PR does not introduce or remove any circular references. This report was generated automatically by comparing against the |
ihexxa
force-pushed
the
fix/script/cookies
branch
2 times, most recently
from
July 31, 2026 07:34
71dff49 to
17c86b2
Compare
ihexxa
force-pushed
the
fix/script/cookies
branch
from
August 4, 2026 07:46
17c86b2 to
e0d8962
Compare
ihexxa
marked this pull request as ready for review
August 4, 2026 08:12
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the scripting API for response cookies so .response.cookies.toObject() returns a { [key]: value } map (matching Postman SDK semantics) instead of an array of cookie JSON objects, and updates typing/tests to reflect the behavior.
Changes:
- Updated
PropertyList.toObject()typing to allow subclasses to return an object shape. - Implemented
CookieList.toObject()to return a key/value map of cookie names to values (and inherited byCookieObject). - Added unit tests covering empty/non-empty cookie lists for
toObject().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/insomnia-scripting-environment/src/objects/properties.ts | Widens PropertyList.toObject() return type to support object-returning overrides. |
| packages/insomnia-scripting-environment/src/objects/cookies.ts | Overrides CookieList.toObject() to return a cookie name → value map. |
| packages/insomnia-scripting-environment/src/objects/tests/cookies.test.ts | Adds tests asserting the new toObject() behavior for CookieList and CookieObject. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+213
to
+226
| const cookieObject = new CookieObject({ | ||
| _id: '', | ||
| type: 'CookieJar', | ||
| parentId: '', | ||
| modified: 0, | ||
| created: 0, | ||
| isPrivate: false, | ||
| name: 'my jar', | ||
| cookies: [ | ||
| { id: '1', key: 'c1', value: 'v1', domain: 'inso.com' }, | ||
| { id: '2', key: 'c2', value: 'v2', domain: 'inso.com' }, | ||
| ], | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| } as any); |
Comment on lines
+191
to
+197
| override toObject(_excludeDisabled?: boolean, _caseSensitive?: boolean, _multiValue?: boolean, _sanitizeKeys?: boolean) { | ||
| const obj: Record<string, string> = {}; | ||
| this.list.forEach(cookie => { | ||
| obj[cookie.key] = cookie.valueOf(); | ||
| }); | ||
| return obj; | ||
| } |
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.
Summary
.response.cookies.toObject()in scripts so it returns a proper{ key: value }object instead of an array of raw cookie JSON blobs, matching Postman SDK semantics.CookieList.toObject()(inpackages/insomnia-scripting-environment/src/objects/cookies.ts) now overrides the basePropertyList.toObject()to build aRecord<string, string>map from each cookie'skey/value;CookieObjectinherits the same fix since it extendsCookieList.PropertyList.toObject()'s return type toRecord<string, any> | Record<string, any>[]so subclasses can narrow to an object shape.