Skip to content

fix(script): setting invalid value to environment value should be rejected - INS-2957#10249

Draft
ihexxa wants to merge 6 commits into
developfrom
fix/nil-var
Draft

fix(script): setting invalid value to environment value should be rejected - INS-2957#10249
ihexxa wants to merge 6 commits into
developfrom
fix/nil-var

Conversation

@ihexxa

@ihexxa ihexxa commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Background

If some invalid values are set to environment in script, an error ""Execute pre-request script failed: Cannot convert undefined or null to object" will be displayed.

Changes

  • setting invalid value (undefined, NaN) to environment value should be rejected.
  • Allow setting null to an environment value.

INS-2957

@ihexxa ihexxa self-assigned this Jul 14, 2026
Copilot AI review requested due to automatic review settings July 14, 2026 08:34

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 updates the scripting environment variable APIs to reject invalid assignments (null/undefined/NaN) and fixes variable lookup precedence so falsy values (e.g., 0, '', false) don’t incorrectly fall through to lower-precedence scopes.

Changes:

  • Reject null, undefined, and NaN in Environment.set() / Variables.set() with a warning instead of storing the value.
  • Fix Variables.get() to resolve variables by key presence (not truthiness), preserving falsy values.
  • Add unit tests covering falsy value precedence and invalid-value rejection (with one test assertion needing correction).

Reviewed changes

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

File Description
packages/insomnia-scripting-environment/src/objects/environments.ts Reject invalid env assignments and fix Variables.get() precedence for falsy values.
packages/insomnia-scripting-environment/src/objects/tests/environments.test.ts Add coverage for falsy precedence and invalid-value rejection warnings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

✅ Circular References Report

Generated at: 2026-07-17T09:06:05.115Z
Status: ✅ NO CHANGE

Summary

Metric Base (develop) PR Change
Total Circular References 9 9 0 (0.00%)
Click to view all circular references in PR (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

No Change: This PR does not introduce or remove any circular references.


This report was generated automatically by comparing against the develop branch.

@ihexxa ihexxa changed the title fix(script): setting invalid value to environment value should be rejected fix(script): setting invalid value to environment value should be rejected - INS-2957 Jul 14, 2026
@ihexxa
ihexxa requested a review from a team July 14, 2026 10:17
@ihexxa
ihexxa marked this pull request as draft July 17, 2026 08: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.

2 participants