Skip to content

fix: update cookieJar methods to keep the name and params consistent - #8654

Merged
ZxBing0066 merged 3 commits into
developfrom
fix/insistent-cookie-jar-function-name-and-body
Apr 29, 2025
Merged

fix: update cookieJar methods to keep the name and params consistent#8654
ZxBing0066 merged 3 commits into
developfrom
fix/insistent-cookie-jar-function-name-and-body

Conversation

@ZxBing0066

Copy link
Copy Markdown
Member

Background

When using a template to get the cookie, it throws an error.

{% request 'cookie', 'test', '' %}

iShot_2025-04-28_17 21 16

Root cause

There are two issues:

  • We mostly use cookieJar.getOrCreateForParentId, but use getOrCreateForWorkspace in templating-worker-database.ts to match the message.
  • templating-worker-database.ts uses body.id as the parent id, but the real param name used in base-extension-worker.ts is body.parentId.

Changes

  • Unify all the getOrCreateForWorkspace to getOrCreateForParentId to avoid similar issues.
  • Change the getOrCreateForParentId param from workspace to parentId to match the new name
  • Fix the wrong used parameter

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR unifies cookieJar method naming and parameter usage to prevent errors when retrieving cookies by ensuring consistency across modules.

  • Changed cookieJar calls in template tags to use getOrCreateForParentId with workspace._id
  • Updated type definitions and method implementations in base-extension, base-extension-worker, and templating-worker-database

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/insomnia/src/ui/components/templating/local-template-tags.ts Updated cookieJar calls to use getOrCreateForParentId with workspace._id
packages/insomnia/src/templating/types.ts Modified cookieJar type to require a parentId parameter
packages/insomnia/src/templating/base-extension.ts Refactored cookieJar method call to use getOrCreateForParentId
packages/insomnia/src/templating/base-extension-worker.ts Updated cookieJar fetch call to use parentId in request body
packages/insomnia/src/main/templating-worker-database.ts Adjusted lookup logic to expect getOrCreateForParentId with body.parentId

@ZxBing0066
ZxBing0066 marked this pull request as ready for review April 28, 2025 10:01
@ZxBing0066
ZxBing0066 enabled auto-merge (squash) April 28, 2025 10:02

@cwangsmv cwangsmv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ZxBing0066
ZxBing0066 merged commit 1f9be6b into develop Apr 29, 2025
@ZxBing0066
ZxBing0066 deleted the fix/insistent-cookie-jar-function-name-and-body branch April 29, 2025 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants