fix(discovery): run VS Code settings before the blind scans, and never invent a password - #189
Merged
Conversation
…r invent a password (#187) The fork's VS Code / Server Manager reader was written, wired and tested, and could not run. Two defects, one behavioural change each. PRECEDENCE. discover_iris() had VS Code settings as step 6 of 6, behind the localhost port scan and the Docker scan. On any machine where IRIS answers on localhost or in a container — which is every machine anyone runs this on — a scan won first and .vscode/settings.json was never opened. It is now step 4, directly after IRIS_CONTAINER and ahead of both scans, for the reason step 3's own comment already gave: explicit configuration names WHICH instance the user means, and a port scan cannot tell one IRIS on 52773 from another. BEHAVIOUR CHANGE, and the reason this is a minor bump: a workspace whose settings.json names an instance different from whatever answers on localhost:52773 now connects to the one it names. That is the fix, but it will move some people's connection. `"active": false` opts an entry out. CREDENTIALS. to_iris_connection() ended `unwrap_or("SYS")` in both the named-server and the direct-host paths. Server Manager deliberately does not write the password into settings.json — it keeps it in the OS keychain, which this binary cannot read — so the commonest real entry hit that default and produced a connection that looked configured and could only ever 401, with nothing naming the cause. It is now VsCodeResolution: Resolved / NotConfigured / MissingPassword{server}. The Option it replaced collapsed "nothing configured here" and "configured but no password" into one None, which is what made fabricating the password look reasonable. The password falls back to $IRIS_PASSWORD — the intended composition, VS Code supplying host, port and namespace while the environment supplies the secret — and when there is none, discovery warns naming the file, the server and the keychain, then continues instead of stopping on a connection that cannot work. Username keeps its _SYSTEM default: it is not a secret, it is this codebase's documented default everywhere else, and Server Manager does write it. An empty string counts as absent. A `server:` name with no matching entry is a typo and now resolves to NotConfigured rather than guessing localhost. Tests: 8 new in vscode_config_tests.rs covering both paths, the env fallback, inline beating env, empty-as-missing, active:false and the dangling name. Mutation control run — restoring `unwrap_or("SYS")` turns exactly the three no-password tests red with the fabricated value in the message, and leaves the other ten green. STILL OPEN in #187: only one search path, current_dir()/.vscode/settings.json. User-scope VS Code settings — where Server Manager normally keeps servers — are still not read, so a server added through its UI rather than written into the workspace is still not found. There is still no keychain reader; the absent password is now reported, not invented. The module header and the README both carried the "last step" claim and both move with the code. Version 0.17.0 — also releases the #179 line-map fix, on master since ec014d6. Refs #187 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The CI 'test' job runs 'cargo fmt --all -- --check' before the suites; my local gate was clippy + cargo test, which does not cover it. Formatting only. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The VS Code / Server Manager reader in this fork was written, wired into the cascade and unit-tested — and could not run. Two defects, one behaviour change each.
Precedence
discover_iris()had VS Code settings as step 6 of 6, behind the localhost port scan and the Docker scan. On any machine where IRIS answers on localhost or in a container — which is every machine anyone runs this on — a scan won first and.vscode/settings.jsonwas never opened.It is now step 4, directly after
IRIS_CONTAINERand ahead of both scans, for the reason step 3's own comment already gave:Explicit configuration names which instance the user means; a port scan cannot tell one IRIS on 52773 from another. That reasoning was already in the file, applied to the named-container case only.
Important
This moves some people's connection, and is why the bump is minor. A workspace whose
settings.jsonnames an instance different from whatever answers onlocalhost:52773now connects to the one it names."active": falseopts an entry out.Credentials
to_iris_connection()endedunwrap_or("SYS")in both the named-server and direct-host paths. Server Manager deliberately does not write the password intosettings.json— it keeps it in the OS keychain, which this binary cannot read — so the commonest real entry hit that default and produced a connection that looked configured and could only ever 401, with nothing naming the cause.The
Option<IrisConnection>it returned collapsed "nothing configured here" and "configured but no password" into oneNone, which is what made inventing the password look reasonable. It is now explicit:$IRIS_PASSWORD— the intended composition: VS Code supplies host, port and namespace, the environment supplies the secret that lives in the keychain._SYSTEMdefault: not a secret, this codebase's documented default everywhere else, and Server Manager does write it. The password is the field it withholds, so the password is the one we refuse to invent.server:name with no matching entry is a typo and resolves toNotConfiguredrather than guessing localhost.Tests
8 new in
vscode_config_tests.rs— both paths, env fallback, inline beating env, empty-as-missing,active:false, dangling name, and apathPrefixregression guard. 13/13 green, full workspace green, clippy clean (verified with a positive control: the same pipeline reports 1922 warnings under-W clippy::pedantic, so the empty default run is real).Mutation control — restoring
unwrap_or("SYS")turns exactly the three no-password tests red, with the fabricated value quoted in the failure message, and leaves the other ten green:Scope — issue 187 stays open
One item deliberately untouched:
discover_via_vscode_settingsstill searches exactly one path,current_dir()/.vscode/settings.json. User-scope VS Code settings — where Server Manager normally keeps servers — are still not read, so a server added through its UI rather than written into the workspace is still not found. There is still no keychain reader; an absent password is now reported rather than invented. Issue 187 stays open for the search-path item.Also
The module header and the README both carried the "last step" claim; both move with the code. Version 0.17.0, which also releases the #179 line-map fix that has been on master since
ec014d6.Refs #187
🤖 Generated with Claude Code