Skip to content

fix(synology-chat): respect SYNOLOGY_RATE_LIMIT=0 in env var parsing#39197

Closed
scoootscooob wants to merge 1 commit intoopenclaw:mainfrom
scoootscooob:fix/synology-rate-limit-zero
Closed

fix(synology-chat): respect SYNOLOGY_RATE_LIMIT=0 in env var parsing#39197
scoootscooob wants to merge 1 commit intoopenclaw:mainfrom
scoootscooob:fix/synology-rate-limit-zero

Conversation

@scoootscooob
Copy link
Copy Markdown
Contributor

Summary

  • Replace parseInt(envRateLimit, 10) || 30 with a proper parse that uses Number.isFinite() to validate
  • parseInt("0", 10) returns 0 which || treats as falsy, silently defaulting to 30
  • The new approach correctly handles both 0 (valid rate limit) and NaN (invalid input falls back to 30)

Test plan

  • Added test: respects SYNOLOGY_RATE_LIMIT=0 instead of defaulting to 30
  • All 12 synology-chat account tests pass

Fixes #39191

🤖 Generated with Claude Code

parseInt(envRateLimit, 10) || 30 drops valid 0 because 0 is falsy.
Switch to ?? (nullish coalescing) so only NaN triggers the default.

Fixes openclaw#39191

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a subtle falsy-value bug in the SYNOLOGY_RATE_LIMIT environment variable parsing inside extensions/synology-chat/src/accounts.ts. The original expression parseInt(envRateLimit, 10) || 30 silently fell back to 30 when the env var was set to "0" because JavaScript's || operator treats 0 as falsy. The fix replaces this with a proper Number.isFinite() guard so that 0 is honoured as a valid rate limit while non-numeric and unset inputs still fall back to 30.

  • Root cause fixed: parseInt("0", 10) returns 0; 0 || 30 evaluates to 30 — now replaced with Number.isFinite(parsedRateLimit) ? parsedRateLimit : 30.
  • All edge cases handled correctly: unset env var → NaN30; "0"0; non-numeric string (e.g. "abc") → NaN30.
  • Regression test added: a new test case respects SYNOLOGY_RATE_LIMIT=0 instead of defaulting to 30 directly exercises the previously broken path and relies on the existing beforeEach cleanup to avoid state leakage.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, well-tested bug fix with no risk of regression.
  • The change is two lines in the source and one new test. The logic is provably correct for all relevant inputs (undefined, "0", valid integers, non-numeric strings). The existing test suite is left intact and the new test directly covers the previously broken case. No architectural changes or refactoring present.
  • No files require special attention.

Last reviewed commit: 5629a3d

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5629a3ddac

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +66 to +67
const parsedRateLimit = envRateLimit != null ? parseInt(envRateLimit, 10) : NaN;
const envRateLimitValue = Number.isFinite(parsedRateLimit) ? parsedRateLimit : 30;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject partially numeric rate-limit env values

Using parseInt with Number.isFinite treats malformed values that start with zero (for example SYNOLOGY_RATE_LIMIT=0abc or 0x10) as valid 0, so this change now accepts those inputs instead of falling back to 30 as before. That silently changes runtime throttling behavior for misconfigured deployments and can unexpectedly clamp message throughput; the env value should only be accepted when the entire string is a valid integer.

Useful? React with 👍 / 👎.

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Mar 8, 2026

Landed on main after rebasing onto the latest origin/main.

What shipped:

  • honor SYNOLOGY_RATE_LIMIT=0 as an explicit rate limit instead of falling back to 30
  • tighten env parsing so malformed values like 0abc still fall back to the default instead of being partially parsed
  • added regression coverage for both the explicit 0 case and malformed-value fallback
  • updated CHANGELOG.md
  • ran pnpm lint, pnpm build, and pnpm test

Landed commit:

Source PR commit:

Thanks @scoootscooob.

@steipete steipete closed this Mar 8, 2026
mcaxtr pushed a commit to mcaxtr/openclaw that referenced this pull request Mar 8, 2026
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 22, 2026
Landed from contributor PR openclaw#39197 by @scoootscooob.

Co-authored-by: scoootscooob <[email protected]>
(cherry picked from commit af9d76b)
alexey-pelykh added a commit to remoteclaw/remoteclaw that referenced this pull request Mar 22, 2026
… CI fixes (#1794)

* fix: honor explicit Synology Chat rate-limit env values

Landed from contributor PR openclaw#39197 by @scoootscooob.

Co-authored-by: scoootscooob <[email protected]>
(cherry picked from commit af9d76b)

* fix: honor zero-valued voice-call STT settings

Landed from contributor PR openclaw#39196 by @scoootscooob.

Co-authored-by: scoootscooob <[email protected]>
(cherry picked from commit 28b72e5)

* fix: honor explicit OpenAI TTS speed values

Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
(cherry picked from commit 442f2c3)

* Voice Call: allowlist realtime STT api key fixtures

(cherry picked from commit b8b6569)

* Voice Call: read TTS internals in tests

(cherry picked from commit b1f7cf4)

* Voice Call: read realtime STT internals in tests

(cherry picked from commit 244aabb)

* test: fix gate regressions

(cherry picked from commit 56cd008)

* refactor: normalize voice-call runtime defaults

(cherry picked from commit 3087893)

* refactor: preserve explicit mock voice-call values

(cherry picked from commit f6c7ff3)

* fix(ci): resolve type regressions on main

(cherry picked from commit f721141)

* refactor(voice-call): share tts deep merge

(cherry picked from commit ed43743)

* fix: land openclaw#33992 from @darkamenosa

Co-authored-by: Tom <[email protected]>
(cherry picked from commit fcdc1a1)

* fix(ci): repair zalouser CI failures

(cherry picked from commit 06ffef8)

* fix: resolve cherry-pick type errors in zalouser extension

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: resolve cherry-pick type error in voice-call config test — adapt SecretRef to string apiKey

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: ql-wade <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: Tom <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: synology-chat ignores SYNOLOGY_RATE_LIMIT=0 (parseInt || 30 truthy check)

2 participants