Repository navigation
fix(blender,freecad): keep a blank port in the config from killing the server - #69
Merged
Merged
Conversation
…e server
Both launchable-app servers read their port with int(get_env(...)) inside
on_start() -> probe(), which runs once the transport is open and before the MCP
initialize handshake. A `BLENDER_PORT=` line -- what `--set BLENDER_PORT=` writes,
since set_config filters None but not "" -- makes get_env return an empty string
instead of the documented default, and int('') aborts the whole server with a raw
ValueError instead of the actionable "Could not connect to Blender at ..." message.
shared.env._int_env already encodes this rule for the QWEN_MM_* knobs ("a bad value
must not crash the server"), and tests/test_env_config.py exists to lock it in. This
completes the migration for the plain integers: a new get_int_env sibling of
get_bool_env falls back to the default for unset/blank/unparseable values, and the
six port reads go through it.
This was referenced Oct 1, 2026
Collaborator
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed
Six port reads go from
int(get_env(...))to a newshared.env.get_int_env(...), so a port the loadercannot parse falls back to the documented default instead of aborting.
BLENDER_PORTblenderloader.get_connection/loader.probe/_launchValueErrorout ofint('')9876FREECAD_RPC_PORTfreecadloader.get_connection/loader.probe/_launchValueErrorout ofint('')9875get_int_envis a sibling of the existingget_bool_envinsrc/shared/env.py, and it follows therule the repo already committed to for the
QWEN_MM_*knobs —_int_env's docstring says a bad value"logs a warning and falls back to the default instead of raising", and
tests/test_env_config.pyopens with "a bad size/timeout config value must NOT crash the server". Unset, blank, and whitespace
count as unset; an unparseable value warns with the var name and returns the default. Unlike
_int_envit takes a plain integer, because a port has no byte-size spelling to accept.Two of the six sites are the reason this matters more than a typo:
on_start()→probe()runs oncethe transport is open and before the MCP initialize handshake (
mcp_framework.py:279), so theraise kills the server rather than one tool call; and in
get_connection()the raise replaces thecareful
Could not connect to Blender at host:port …guidance with a bare traceback.Before / after, same poisoned config
--set BLENDER_PORT=on the real CLI stores the blank line in the config file the server reads(
~/.qwen-mm-plugins/config, or$QWEN_MM_CONFIG), thenloader.probe()runs on each checkout:The second line is the behaviour the code already wants for a stopped Blender — the config parse
failure was preempting it, so the user never saw the actionable hint.
Why a blank value is reachable through the documented interface
--setis documented as the non-interactive path "for automation", andset_configfiltersNonebut not
""(shared/env.py:122), so--set BLENDER_PORT=$PORTwithPORTunset storesBLENDER_PORT=. That line is whatget_envthen returns instead of the default. The repo already treats storing one as wrong in theother two write paths —
del_config's docstring ("Clearing must delete the line, not writeKEY=—an empty config value would shadow a real default",
shared/env.py:130),install.sh:1668(
elif [ -n "$newv" ]) and--setup(mcp_framework.py:425,if not v: continue; the docstring at:400states the rule outright: "blank keeps the current value,-clears it (removed, not writtenempty)"). This PR fixes the readers rather than changing
--set'scontract, so a config file that is already poisoned stops breaking on upgrade.
Verification
RED/GREEN for the new startup regression:
7f7ca38's own source in a separate checkout:2 failed,ValueError: invalid literal for int() with base 10: ''atblender/loader.py:192andfreecad/loader.py:169tests/test_env_config.pyon this branch:34 passedThe full suite was run on Windows, where CI has no test job (the matrix is ubuntu + macOS and the
windows job only checks out): 15 failed / 1056 passed / 97 skipped on this branch and
16 failed / 1046 passed / 97 skipped on the untouched
7f7ca38checkout, with identical failurelists apart from
test_isolated_worker.py::test_isolated_worker_timeout, a subprocess-spawnPermissionErrorthat failed onmainin its full run and passed there when re-run alone, and theother way round on this branch. The remaining 15 names are bash-/POSIX-dependent
(
test_install_sh.py,test_tag_plugin_release.py) or Windows-path-dependent (test_mhs.py,test_omni_*.py); since the two lists otherwise match line for line, this change adds no failure.No tool name, input schema or output changed, so no docs or
plugin-versions.jsonupdate is needed.Two things I deliberately left out
src/capabilities/video-memory/skill/script/build_memory/build_graph.py:55has the sameint(get_env("OSS_URL_EXPIRY", …))shape, but that tree reads a trimmed private copy of the envmodule (
build_memory/env_config.py, noget_int_envin it), so fixing it is a separate changewith a different blast radius. Happy to follow up.
--set KEY=refuse to write the blank line (matching--setup) is arguably the other half ofthis. I kept it out to keep this PR to one concern; the reader fix alone already covers both the
--setand the hand-edited-file cases.Relates to #60 — that PR routes four on/off flags through
get_bool_env; this one covers theinteger reads, so different settings and different behaviour. We do both touch
src/capabilities/freecad/qwen_mm_plugins_freecad/loader.py, on two separate lines: itsonly_text_feedback()body, and this file's import plus the two port reads. If #60 lands first thefrom shared.env import …line needsboth names, which is a one-word merge.
Fixes #68