OSW_CRED_FILEPATH=~/accounts.pwd.yaml fails with "does not exist", although the file does exist.
Path("~/accounts.pwd.yaml").is_file() is False, because pathlib never expands ~ by itself. The check at
https://github.com/OpenSemanticLab/osw-python/blob/feat/mcp-server/src/osw/service/config.py#L634 therefore reports the file as missing:
RuntimeError: Configured credential file '~/accounts.pwd.yaml' does not exist. Set OSW_CRED_FILEPATH (...)
The second reader, open(cred_filepath, encoding="utf-8") at
https://github.com/OpenSemanticLab/osw-python/blob/feat/mcp-server/src/osw/service/config.py#L213, has the same gap, but the check above runs first.
Why this is worth fixing
The failure is loud, not silent, so no credential ever goes to the wrong place. The problem is the message: it says the file does not exist while the file is there, so it points the operator at the wrong cause.
OSW_STATE_DIR now expands a leading ~ (#133). The two path settings therefore disagree, and an operator who learns the rule from one gets the opposite result from the other.
Suggested fix
Expand ~ in Settings._validate_cred_filepath (https://github.com/OpenSemanticLab/osw-python/blob/feat/mcp-server/src/osw/service/config.py#L169), the same way _validate_state_dir does, including the RuntimeError catch for an undeterminable home directory.
Unlike state_dir, a relative cred_filepath should stay accepted. The CLI already resolves accounts.pwd.yaml against the working directory on purpose.
Reproduction
printf 'wiki.example.org:\n username: u\n password: p\n' > ~/accounts.pwd.yaml
OSW_DOMAIN=wiki.example.org OSW_CRED_FILEPATH='~/accounts.pwd.yaml' osw status
OSW_CRED_FILEPATH=~/accounts.pwd.yamlfails with "does not exist", although the file does exist.Path("~/accounts.pwd.yaml").is_file()isFalse, becausepathlibnever expands~by itself. The check athttps://github.com/OpenSemanticLab/osw-python/blob/feat/mcp-server/src/osw/service/config.py#L634 therefore reports the file as missing:
The second reader,
open(cred_filepath, encoding="utf-8")athttps://github.com/OpenSemanticLab/osw-python/blob/feat/mcp-server/src/osw/service/config.py#L213, has the same gap, but the check above runs first.
Why this is worth fixing
The failure is loud, not silent, so no credential ever goes to the wrong place. The problem is the message: it says the file does not exist while the file is there, so it points the operator at the wrong cause.
OSW_STATE_DIRnow expands a leading~(#133). The two path settings therefore disagree, and an operator who learns the rule from one gets the opposite result from the other.Suggested fix
Expand
~inSettings._validate_cred_filepath(https://github.com/OpenSemanticLab/osw-python/blob/feat/mcp-server/src/osw/service/config.py#L169), the same way_validate_state_dirdoes, including theRuntimeErrorcatch for an undeterminable home directory.Unlike
state_dir, a relativecred_filepathshould stay accepted. The CLI already resolvesaccounts.pwd.yamlagainst the working directory on purpose.Reproduction