-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(onboard): fall back on a negative timeout or poll override #7891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3cca519
fix(onboard): fall back on a negative timeout or poll override
yanyunl1991 b705588
test(onboard): prove the supplied env map wins over the process envir…
yanyunl1991 c96b32f
Merge branch 'main' into fix/envint-rejects-negative-7881
senthilr-nv e50accf
Merge branch 'main' into fix/envint-rejects-negative-7881
prekshivyas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // `envInt` backs the poll counts, poll intervals and readiness budgets used | ||
| // across onboarding and gateway recovery. A negative override used to be | ||
| // clamped to 0, which is the most damaging reading available for every one of | ||
| // those knobs, while any other invalid value already fell back (#7881). | ||
|
|
||
| import { describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { envInt } from "./env"; | ||
|
|
||
| const FALLBACK = 30; | ||
|
|
||
| function read(value: string | undefined): number { | ||
| return envInt("NEMOCLAW_TEST_KNOB", FALLBACK, { NEMOCLAW_TEST_KNOB: value }); | ||
| } | ||
|
|
||
| describe("envInt override parsing", () => { | ||
| it.each([ | ||
| "-1", | ||
| "-30", | ||
| "-0.4", | ||
| "-1e3", | ||
| ])("falls back instead of collapsing a negative override (%s) to zero", (value) => { | ||
| expect(read(value)).toBe(FALLBACK); | ||
| }); | ||
|
|
||
| it.each([ | ||
| "abc", | ||
| "NaN", | ||
| "Infinity", | ||
| "-Infinity", | ||
| ])("keeps falling back for a non-finite override (%s)", (value) => { | ||
| expect(read(value)).toBe(FALLBACK); | ||
| }); | ||
|
|
||
| it.each([ | ||
| ["unset", undefined], | ||
| ["empty", ""], | ||
| ])("keeps falling back for an %s override", (_label, value) => { | ||
| expect(read(value)).toBe(FALLBACK); | ||
| }); | ||
|
|
||
| it("still accepts an explicit zero", () => { | ||
| // Regression lock: callers that read 0 as "disabled" or clamp it upward | ||
| // themselves must keep seeing 0, so this fix cannot change their meaning. | ||
| expect(read("0")).toBe(0); | ||
| }); | ||
|
|
||
| it.each([ | ||
| ["3", 3], | ||
| ["0.4", 0], | ||
| ["2.6", 3], | ||
| ["600", 600], | ||
| ])("keeps rounding a valid override (%s)", (value, expected) => { | ||
| expect(read(value)).toBe(expected); | ||
| }); | ||
|
|
||
| it("uses the supplied env map rather than the process environment", () => { | ||
| // Both assertions need a conflicting process value to have any teeth: with | ||
| // `process.env` unset, an implementation that ignored the supplied map | ||
| // would return the fallback here and still pass. | ||
| vi.stubEnv("NEMOCLAW_TEST_KNOB", "999"); | ||
| try { | ||
| expect(envInt("NEMOCLAW_TEST_KNOB", FALLBACK, { NEMOCLAW_TEST_KNOB: "7" })).toBe(7); | ||
| expect(envInt("NEMOCLAW_TEST_KNOB", FALLBACK, {})).toBe(FALLBACK); | ||
| } finally { | ||
| vi.unstubAllEnvs(); | ||
| } | ||
| }); | ||
| }); | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.