Repository navigation
fix: remove the 50 cap on maxRedirects and normalise it on every read path - #8855
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe PR centralizes ChangesMax redirects normalization
Clipboard test isolation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant PostmanCollection
participant PostmanImporter
participant BrunoCollection
participant WarningIssues
PostmanCollection->>PostmanImporter: import request maxRedirects
PostmanImporter->>PostmanImporter: normalize value
alt valid value
PostmanImporter->>BrunoCollection: store normalized setting
else invalid value
PostmanImporter->>WarningIssues: record request warning
PostmanImporter->>BrunoCollection: use default during import
end
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
cb4453f to
f517738
Compare
f517738 to
98c73b2
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-schema/src/collections/itemSchema.spec.js`:
- Around line 92-133: Terminate all changed JavaScript and TypeScript statements
with semicolons: add semicolons throughout the tests in
packages/bruno-schema/src/collections/itemSchema.spec.js:92-133 and
packages/bruno-converters/tests/postman/postman-to-bruno/max-redirects.spec.js:1-76,
both exported helper declarations in
packages/bruno-converters/tests/common/postman-collection.js:1-19, the
maxRedirects declaration and assignment in postman-to-bruno.js:596-604, the
import in partial-import.spec.js:3, and the new statements in
tests/import/postman/import-postman-max-redirects.spec.ts:1-110.
In `@tests/import/postman/import-postman-max-redirects.spec.ts`:
- Around line 93-102: Update the import issues test around the warning toast
assertions to verify all four expected request-specific warning messages through
the import issues UI, alongside the existing warning count. Remove the negative
skipped-text assertion and preserve the checkbox visibility check for warnings
without request data.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2d7b63f5-3718-4ecd-b4c6-2254adf77f66
📒 Files selected for processing (8)
packages/bruno-converters/src/postman/postman-to-bruno.jspackages/bruno-converters/tests/common/postman-collection.jspackages/bruno-converters/tests/postman/postman-to-bruno/max-redirects.spec.jspackages/bruno-converters/tests/postman/postman-to-bruno/partial-import.spec.jspackages/bruno-schema/src/collections/index.jspackages/bruno-schema/src/collections/itemSchema.spec.jstests/import/postman/fixtures/postman-with-max-redirects.jsontests/import/postman/import-postman-max-redirects.spec.ts
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
tests/import/postman/import-postman-max-redirects.spec.ts (1)
112-114: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueKeep the
toHaveLengthcall on one line.The coding guidelines prohibit newlines inside function parentheses. This repository does not enforce a strict line length.
Proposed fix
- expect(issuesSummary.match(/Invalid maxRedirects, ignored \(must be a whole number of 0 or more\)/g)).toHaveLength( - OFFENDERS.length - ); + expect(issuesSummary.match(/Invalid maxRedirects, ignored \(must be a whole number of 0 or more\)/g)).toHaveLength(OFFENDERS.length);As per coding guidelines, do not put newlines inside function parentheses.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/import/postman/import-postman-max-redirects.spec.ts` around lines 112 - 114, Reformat the toHaveLength assertion in the max-redirects test so the complete call, including its argument, remains on one line; do not change the assertion or its expected value.Source: Coding guidelines
tests/utils/clipboard.ts (1)
6-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd clipboard override cleanup.
pagefixtures are test-scoped, butcaptureClipboardWritesstill mutates the page-globalnavigator.clipboard.writeTextmethod without restoring it. Return a restore callback and invoke it in cleanup so future clipboard tests can use the browser clipboard.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/utils/clipboard.ts` around lines 6 - 14, Update captureClipboardWrites to save the original navigator.clipboard.writeText implementation, then return cleanup that restores it while retaining access to the captured text. Ensure clipboard test teardown invokes this restore callback so subsequent tests use the browser’s original clipboard behavior.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-cli/src/runner/run-single-request.js`:
- Around line 556-560: Normalize redirect limits with toMaxRedirects instead of
local type and fallback checks: update
packages/bruno-cli/src/runner/run-single-request.js lines 556-560 and
packages/bruno-electron/src/ipc/network/index.js lines 143-147 to pass
request.settings?.maxRedirects ?? request.maxRedirects through toMaxRedirects
before using the value with Axios and the custom redirect loop.
In `@tests/import/postman/import-postman-max-redirects.spec.ts`:
- Around line 15-16: Add boolean maxRedirects coverage in the import test by
adding a Boolean Limit fixture with maxRedirects set to false, then include it
in the imported-request assertions and OFFENDERS. Extend the warning and
fallback assertions so this request must emit one warning and use the fallback
value 5.
---
Nitpick comments:
In `@tests/import/postman/import-postman-max-redirects.spec.ts`:
- Around line 112-114: Reformat the toHaveLength assertion in the max-redirects
test so the complete call, including its argument, remains on one line; do not
change the assertion or its expected value.
In `@tests/utils/clipboard.ts`:
- Around line 6-14: Update captureClipboardWrites to save the original
navigator.clipboard.writeText implementation, then return cleanup that restores
it while retaining access to the captured text. Ensure clipboard test teardown
invokes this restore callback so subsequent tests use the browser’s original
clipboard behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d34e6bc1-cd00-4b20-90d8-4e5c0b4c3e22
📒 Files selected for processing (21)
packages/bruno-app/src/components/RequestPane/Settings/index.jspackages/bruno-cli/src/runner/run-single-request.jspackages/bruno-cli/src/utils/axios-instance.jspackages/bruno-common/src/utils/index.spec.tspackages/bruno-common/src/utils/index.tspackages/bruno-converters/src/opencollection/items/graphql.tspackages/bruno-converters/src/opencollection/items/http.tspackages/bruno-electron/src/ipc/network/axios-instance.jspackages/bruno-electron/src/ipc/network/index.jspackages/bruno-filestore/src/formats/yml/items/parseGraphQLRequest.tspackages/bruno-filestore/src/formats/yml/items/parseHttpRequest.tspackages/bruno-filestore/src/formats/yml/items/stringifyGraphQLRequest.tspackages/bruno-filestore/src/formats/yml/items/stringifyHttpRequest.tspackages/bruno-filestore/src/maxRedirects.spec.tspackages/bruno-lang/v2/src/bruToJson.jspackages/bruno-lang/v2/tests/settings/settings.spec.jspackages/bruno-schema/src/collections/index.jspackages/bruno-schema/src/collections/itemSchema.spec.jstests/import/postman/fixtures/postman-with-max-redirects.jsontests/import/postman/import-postman-max-redirects.spec.tstests/utils/clipboard.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/bruno-schema/src/collections/index.js
- packages/bruno-schema/src/collections/itemSchema.spec.js
- tests/import/postman/fixtures/postman-with-max-redirects.json
Postman allows arbitrarily large maxRedirects, so the schema cap failed the whole import. Values that cannot be honoured (negative, fractional, non-numeric, non-finite) now surface as import warnings instead of costing the request.
parseInt stops at the exponent, so a ceiling Bruno writes as 1e+31 reads back as 1, and toNumber lets Infinity, NaN and negatives through untouched. Parse with Number and apply one rule in the bru parser, both yml parsers and the opencollection converters, on read and on write: a whole number of 0 or more, fractions truncated, anything else falling back to the default. That also makes parse(stringify(x)) stable, where a written 3.5 used to read back as 3. The item schema now requires an integer, which holds because every parser normalizes first. The request pipeline is deliberately left alone, so it still honours whatever a script or an unsaved draft sets.
The fallback assertions hardcoded 5, so they duplicated the value the constant already carries. One test pins the concrete value; the rest go through the constant.
Number.isInteger(true) is false, so it is dropped with a warning like any other unusable value. The unit spec already covered it; this pins it end to end.
b28b4f8 to
421fa84
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
playwright/index.ts (1)
361-366: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winKeep page cleanup independent.
The loop awaits each
page.evaluate()directly. If an open page loses its execution context during navigation or renderer shutdown, that call can reject whilepage.isClosed()is still false. UsePromise.allSettledor catch cleanup errors per page so later pages inpatchedPagesare still cleaned.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@playwright/index.ts` around lines 361 - 366, Update the cleanup loop over patchedPages to handle page.evaluate failures independently per page, such as by collecting cleanup promises with Promise.allSettled or catching each error. Preserve the existing isClosed check and ensure one page’s lost execution context does not prevent cleanup of subsequent pages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@playwright/index.ts`:
- Around line 168-171: In the max-redirects import test, guard the result of
clipboard.copiedText() before calling issuesSummary.match, handling the null
case explicitly while preserving the existing matching behavior for non-null
text.
In `@tests/import/postman/import-postman-max-redirects.spec.ts`:
- Around line 26-31: Move the reusable max-redirects workflow from
expectMaxRedirects into an appropriate page module under tests/utils/page,
including sidebar navigation, Settings tab selection, and the maxRedirectsInput
assertion; update the spec to call that page-module helper. Also relocate the
inline toast locator at line 117 into the page module and replace its spec usage
with the corresponding page abstraction.
---
Nitpick comments:
In `@playwright/index.ts`:
- Around line 361-366: Update the cleanup loop over patchedPages to handle
page.evaluate failures independently per page, such as by collecting cleanup
promises with Promise.allSettled or catching each error. Preserve the existing
isClosed check and ensure one page’s lost execution context does not prevent
cleanup of subsequent pages.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b84fd51d-20ae-4faf-a8aa-47a88017cfda
📒 Files selected for processing (25)
.claude/rules/testing.mdpackages/bruno-app/src/components/RequestPane/Settings/index.jspackages/bruno-cli/src/runner/run-single-request.jspackages/bruno-cli/src/utils/axios-instance.jspackages/bruno-common/src/utils/index.spec.tspackages/bruno-common/src/utils/index.tspackages/bruno-converters/src/opencollection/items/graphql.tspackages/bruno-converters/src/opencollection/items/http.tspackages/bruno-converters/src/postman/postman-to-bruno.jspackages/bruno-converters/tests/common/postman-collection.jspackages/bruno-converters/tests/postman/postman-to-bruno/max-redirects.spec.jspackages/bruno-converters/tests/postman/postman-to-bruno/partial-import.spec.jspackages/bruno-electron/src/ipc/network/axios-instance.jspackages/bruno-electron/src/ipc/network/index.jspackages/bruno-filestore/src/formats/yml/items/parseGraphQLRequest.tspackages/bruno-filestore/src/formats/yml/items/parseHttpRequest.tspackages/bruno-filestore/src/formats/yml/items/stringifyGraphQLRequest.tspackages/bruno-filestore/src/formats/yml/items/stringifyHttpRequest.tspackages/bruno-filestore/src/maxRedirects.spec.tspackages/bruno-lang/v2/src/bruToJson.jspackages/bruno-schema/src/collections/index.jspackages/bruno-schema/src/collections/itemSchema.spec.jsplaywright/index.tstests/import/postman/fixtures/postman-with-max-redirects.jsontests/import/postman/import-postman-max-redirects.spec.ts
🚧 Files skipped from review as they are similar to previous changes (20)
- packages/bruno-schema/src/collections/index.js
- packages/bruno-electron/src/ipc/network/index.js
- packages/bruno-cli/src/utils/axios-instance.js
- packages/bruno-filestore/src/formats/yml/items/stringifyHttpRequest.ts
- packages/bruno-lang/v2/src/bruToJson.js
- packages/bruno-schema/src/collections/itemSchema.spec.js
- tests/import/postman/fixtures/postman-with-max-redirects.json
- packages/bruno-converters/src/opencollection/items/graphql.ts
- packages/bruno-cli/src/runner/run-single-request.js
- packages/bruno-converters/src/postman/postman-to-bruno.js
- packages/bruno-filestore/src/formats/yml/items/parseGraphQLRequest.ts
- packages/bruno-converters/src/opencollection/items/http.ts
- packages/bruno-filestore/src/formats/yml/items/parseHttpRequest.ts
- packages/bruno-converters/tests/common/postman-collection.js
- packages/bruno-electron/src/ipc/network/axios-instance.js
- packages/bruno-app/src/components/RequestPane/Settings/index.js
- packages/bruno-filestore/src/formats/yml/items/stringifyGraphQLRequest.ts
- packages/bruno-converters/tests/postman/postman-to-bruno/max-redirects.spec.js
- packages/bruno-converters/tests/postman/postman-to-bruno/partial-import.spec.js
- packages/bruno-filestore/src/maxRedirects.spec.ts
Description
Ref: BRU-3808
Importing a Postman collection that sets
maxRedirectsabove 50 no longer fails the entire import: the schema cap is gone, and a value Bruno cannot honour is reported as a warning instead of aborting. Every parser and writer now applies one normalization rule, which also fixes a round-trip bug where a ceiling Bruno itself wrote as1e+21was read back as1.Problem
Postman allows an arbitrarily large
maxRedirects, butitemSchemacapped it at 50, so one request over the cap failed validation and took the whole import down with it. Two quieter defects sat behind that. The bru parser read the setting withparseInt, which stops at the exponent, so any ceiling large enough to serialize in exponential form silently became1the next time the request was opened. The yml and OpenCollection paths usedtoNumber, which returns any number untouched, lettingInfinity,NaNand negatives reach the request pipeline from a hand-edited file.Fix
The schema now accepts any whole number of 0 or more (
.integer().min(0)in place of.min(0).max(50)), which is only safe because every parser normalizes before validation runs - the two halves have to ship together.Unusable values warn instead of aborting the import
The Postman importer accepts any number of 0 or more, truncating fractions, and routes anything else (negative, non-numeric, non-finite) to the existing import-issues toast as a per-request warning. The request still imports and falls back to the default, so one malformed value costs a warning rather than the collection.
One normalization rule on every read and write
parseMaxRedirectsin@usebruno/commonis the single rule, used by both yml parsers, all four OpenCollection converter directions, and the yml writers - normalizing on the way out too, soparse(stringify(x))is stable. The bru parser applies the same rule inline, sincebruno-langis a leaf package that cannot importbruno-common. This changes how existing files are read:A previously stored out-of-range value is therefore replaced on the next save. Note also that a value ≥ 1e21 written by this version reads back as
1in older Bruno versions, since theirparseIntis the bug being fixed here.The request pipeline is deliberately untouched
The electron and CLI runners still honour whatever
req.setMaxRedirects()or an unsaved draft sets, without re-validating. No upper bound is reintroduced anywhere.Screenshots
Before:

After:

Contribution Checklist:
Summary by CodeRabbit
New Features
Bug Fixes