Skip to content

fix(naming): encode cache filenames for Windows and path separators - #341

Open
hansu650 wants to merge 1 commit into
nacos-group:masterfrom
hansu650:fix/naming-cache-filenames
Open

hansu650 wants to merge 1 commit into
nacos-group:masterfrom
hansu650:fix/naming-cache-filenames

Conversation

@hansu650

@hansu650 hansu650 commented Dec 1, 2026

Copy link
Copy Markdown

What type of PR is this?

  • Bug fix

What does this PR do?

Percent-encode the naming cache key only when choosing its filename. Service names such as providers:com.example.DemoService:1.0 otherwise fail on Windows, while a single colon can write an NTFS alternate data stream and leave an empty cache file. Slashes can also create nested paths that the cache loader does not read.

In-memory lookups and subscription callbacks continue using the original key. The loader still accepts legacy filenames and keeps the newest lastRefTime when legacy and encoded files describe the same service, so an older snapshot cannot overwrite a newer one during migration.

Which issue(s) does this PR fix?

Fixes #301.

How has this been tested?

Windows / CPython 3.13.15 in a fresh, dedicated environment:

  • 10 new disk-backed regression/control tests pass, including reserved characters in service/group/cluster names, Unicode, literal percent escapes, callback delivery, restart loading and legacy cache migration.
  • Before the fix, the same regression selection reported 7 failures (including one failing migration-order subcase); the ordinary and legacy controls passed.
  • All 56 offline unit tests discovered by python -m unittest discover -s test -p "test_*.py" -v pass.
  • The repository's configured Ruff check, the new test module's F checks, pip check and git diff --check pass.

One existing Pydantic class-config deprecation warning remains. Tests use real temporary files and no Nacos server; live-server integration and other operating systems/Python versions were not run locally.

Checklist

  • Unit tests added/updated
  • Documentation updated if needed: this changes the private cache filename, not the public API
  • Legacy cache contents remain loadable; the on-disk filename change is described above

AI assistance: prepared and validated with OpenAI Codex. The reproduction is based on the user report in #301, not a claim of production deployment.

@CLAassistant

CLAassistant commented Dec 1, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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