Skip to content

Fix non_streaming_server.py crash with --decoding-method modified_beam_search - #3819

Merged
csukuangfj merged 1 commit into
k2-fsa:masterfrom
slipstr34m:fix/nss-modified-beam-search-arg
Jul 29, 2026
Merged

csukuangfj merged 1 commit into
k2-fsa:masterfrom
slipstr34m:fix/nss-modified-beam-search-arg

Conversation

@slipstr34m

@slipstr34m slipstr34m commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

python-api-examples/non_streaming_server.py defines the flag as --max-active-paths (line 434) and consumes args.max_active_paths (line 970), but check_args() asserts on args.num_active_paths, which this script never defines. Starting the server with --decoding-method modified_beam_search (or with --hotwords-file, which check_args gates behind it) has always crashed at startup:

File ".../non_streaming_server.py", line 493, in check_args
    assert args.num_active_paths > 0, args.num_active_paths
AttributeError: 'Namespace' object has no attribute 'num_active_paths'

The gap dates to b094868 (#259), which adapted streaming_server.py (where the flag is consistently --num-active-paths) but renamed the flag without updating check_args. This aligns check_args with the name the script already defines and consumes, keeping the CLI unchanged; the greedy_search path is untouched.

Tested with sherpa-onnx-zipformer-en-2023-04-01: on master the command above crashes as shown; with this change the same command loads the model and binds the port (server listening on 0.0.0.0:16125). A greedy_search control starts cleanly before and after. Hit this while running the server locally for transcription and switching the decoding method.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected validation for the modified beam search option so the configured maximum active paths value is checked properly before recognition starts.

check_args() referenced args.num_active_paths, but this script defines the
flag as --max-active-paths (and consumes args.max_active_paths), so
--decoding-method modified_beam_search crashed with AttributeError at startup.
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 08327e17-1d6b-41e0-8e22-0755f0fb3af9

📥 Commits

Reviewing files that changed from the base of the PR and between 4f97006 and 76c08f0.

📒 Files selected for processing (1)
  • python-api-examples/non_streaming_server.py

📝 Walkthrough

Walkthrough

Corrects modified_beam_search argument validation in the non-streaming Python server to check max_active_paths before recognizer creation.

Changes

Modified beam search validation

Layer / File(s) Summary
Correct maximum active paths validation
python-api-examples/non_streaming_server.py
Validation now requires args.max_active_paths > 0 instead of referencing args.num_active_paths.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: kfrancis

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: a startup crash in non_streaming_server.py when using modified_beam_search.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@csukuangfj csukuangfj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants