Skip to content

fix: nano banana pro 4k(StreamScannerMaxBufferMB env) - #2335

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/nano-banana-pro-4k
Nov 30, 2025
Merged

fix: nano banana pro 4k(StreamScannerMaxBufferMB env)#2335
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/nano-banana-pro-4k

Conversation

@seefs001

@seefs001 seefs001 commented Nov 30, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added STREAM_SCANNER_MAX_BUFFER_MB environment variable (default: 64 MB) to configure stream buffer capacity for optimal large data processing.
  • Documentation

    • Updated configuration guides in multiple languages with the new environment variable settings.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 30, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce a configurable environment variable STREAM_SCANNER_MAX_BUFFER_MB to make the stream scanner's buffer size adjustable. The variable is declared in the constant layer, initialized from environment configuration with a default value of 64MB, and used dynamically in the relay handler instead of relying on a fixed buffer size constant.

Changes

Cohort / File(s) Summary
Documentation Updates
README.md, README.en.md, README.fr.md, README.ja.md
Added STREAM_SCANNER_MAX_BUFFER_MB environment variable entry (default: 64) to configuration tables across all language variants with descriptions indicating per-line buffer size for stream scanner and guidance for large payloads.
Constant Declaration
constant/env.go
Introduced new public package variable StreamScannerMaxBufferMB of type int to store the configurable buffer size.
Configuration Initialization
common/init.go
Added initialization of constant.StreamScannerMaxBufferMB from the STREAM_SCANNER_MAX_BUFFER_MB environment variable with default value 64 inside initConstantEnv function.
Stream Scanner Implementation
relay/helper/stream_scanner.go
Renamed MaxScannerBufferSize constant to DefaultMaxScannerBufferSize, introduced getScannerBufferSize() helper function to dynamically determine buffer size by preferring constant.StreamScannerMaxBufferMB or falling back to default, and updated StreamScannerHandler to use dynamic buffer sizing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the getScannerBufferSize() fallback logic correctly prioritizes environment variable over default
  • Confirm StreamScannerHandler properly passes the dynamic buffer size to the scanner initialization
  • Ensure environment variable initialization in common/init.go follows the existing pattern for other constants

Poem

🐰 A buffer grows, no longer bound,
By fixed constraints, now configurable found!
From env vars dance, the scanner now bends,
Sixty-four megs, or where admin intends! 📊

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title references 'nano banana pro 4k' which appears unrelated to the changeset's primary purpose of adding a configurable StreamScannerMaxBufferMB environment variable for dynamic buffer sizing. Consider a more descriptive title that clearly indicates the change, such as 'feat: make stream scanner buffer size configurable via environment variable' or 'fix: add STREAM_SCANNER_MAX_BUFFER_MB configuration'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
relay/helper/stream_scanner.go (1)

30-35: Consider simplifying or documenting the fallback behavior.

The getScannerBufferSize() function checks if constant.StreamScannerMaxBufferMB > 0, but since this constant is always initialized with a default of 64 (see Line 117 in common/init.go), the else branch returning DefaultMaxScannerBufferSize appears to be unreachable under normal circumstances.

Consider one of the following approaches:

  1. Simplify the function to always use the constant value (since it's always set):
    func getScannerBufferSize() int {
        return constant.StreamScannerMaxBufferMB << 20
    }
  2. Document the special behavior if setting the env var to 0 is intended to use the compiled-in default
  3. Add validation in common/init.go to ensure the value is within a reasonable range (e.g., 1-2048 MB)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 590745b and 2520c8b.

📒 Files selected for processing (7)
  • README.en.md (1 hunks)
  • README.fr.md (2 hunks)
  • README.ja.md (1 hunks)
  • README.md (1 hunks)
  • common/init.go (1 hunks)
  • constant/env.go (1 hunks)
  • relay/helper/stream_scanner.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
common/init.go (1)
constant/env.go (1)
  • StreamScannerMaxBufferMB (6-6)
relay/helper/stream_scanner.go (1)
constant/env.go (1)
  • StreamScannerMaxBufferMB (6-6)
🔇 Additional comments (7)
README.en.md (1)

306-306: LGTM!

The documentation clearly explains the purpose of the new environment variable and provides helpful guidance about when to increase the buffer size (large upstream payloads like 4K images). The default value of 64MB is reasonable and matches the implementation.

README.fr.md (1)

302-302: LGTM!

The French documentation accurately describes the new environment variable with appropriate context about SSE scanner buffer limits and 4K image handling.

README.md (1)

300-309: LGTM!

The Chinese documentation is clear and provides good context about when to adjust the buffer size (超大 data: 片段, such as 4K image base64). The table reformatting improves readability.

constant/env.go (1)

6-6: LGTM!

The new variable declaration follows the established pattern for environment-driven configuration constants in this package.

common/init.go (1)

117-117: LGTM!

The initialization correctly reads the environment variable with a sensible default of 64MB. The value is used in relay/helper/stream_scanner.go to configure the scanner buffer size dynamically.

README.ja.md (1)

311-311: LGTM!

The Japanese documentation accurately describes the buffer configuration with helpful context about handling large base64 data payloads (4K images).

relay/helper/stream_scanner.go (1)

105-105: LGTM!

The dynamic buffer sizing using getScannerBufferSize() correctly addresses the issue with large upstream payloads (4K images, etc.) by making the buffer size configurable through the environment variable.

@Calcium-Ion
Calcium-Ion merged commit 46a18c4 into QuantumNous:main Nov 30, 2025
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
fix: nano banana pro 4k(StreamScannerMaxBufferMB env)
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