Skip to content

Fix config save stripping backslashes from property values#617

Open
NiccoMlt wants to merge 1 commit into
diennea:masterfrom
NiccoMlt:608-config-save-strips-backslashes-from-property-values-connection-pool-domain-regexes-break
Open

Fix config save stripping backslashes from property values#617
NiccoMlt wants to merge 1 commit into
diennea:masterfrom
NiccoMlt:608-config-save-strips-backslashes-from-property-values-connection-pool-domain-regexes-break

Conversation

@NiccoMlt

@NiccoMlt NiccoMlt commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Every config save re-serializes the whole configuration as raw key=value text and re-parses it with Properties.load(), which treats \ as an escape and silently drops it.

Thus, any backslash-bearing value is corrupted: a connection-pool domain like (\Qhost.example\E) becomes (Qhost.exampleE), the regex stops matching, and traffic silently falls back to the default pool. Both the connection-pool CRUD API and the config editor hit this path.

Implementation

Make the round-trip symmetric: toStringConfiguration() now serializes with Properties.store(), which escapes values exactly as load() expects. The timestamp comment store() prepends is stripped and lines are kept sorted, preserving the deterministic dump format.

Fixes #608

toStringConfiguration() emitted raw key=value text, but every save
re-parses it with Properties.load(), which eats backslashes: pool
domain regexes like (\Qhost\E) silently became (QhostE) and stopped
matching. Serialize with Properties.store() so the round-trip is
symmetric.

Fixes diennea#608
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 304b42e5-b217-41bc-8282-b3f1aa8e0b85

📥 Commits

Reviewing files that changed from the base of the PR and between 58d49cb and 25cb99f.

📒 Files selected for processing (3)
  • carapace-server/src/main/java/org/carapaceproxy/configstore/ConfigurationStore.java
  • carapace-server/src/test/java/org/carapaceproxy/api/ConnectionPoolsResourceTest.java
  • carapace-server/src/test/java/org/carapaceproxy/configstore/ConfigurationStoreTest.java

📝 Walkthrough

Walkthrough

Summary
ConfigurationStore.toStringConfiguration() now uses Properties.store(...), removes generated timestamp comments, sorts serialized entries, and returns newline-terminated output. Tests cover repeated configuration round-trips and connection-pool saves containing regex backslashes.

Assessment against linked issues

Objective Addressed Explanation
Preserve backslashes in all serialized configuration values, including pool domains and request matchers [#608]
Prevent regex domains from being corrupted after subsequent configuration saves [#608]
Add regression coverage for the reported save path [#608]

Poem

I’m a rabbit with regex ears,
Hopping past escaped-backslash fears.
\Q and \E stay in line,
Through every save, they remain fine.
Config blooms, neat and bright—
No lost slashes in the night!

✨ 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.

@NiccoMlt NiccoMlt self-assigned this Jul 21, 2026
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.

Config save strips backslashes from property values (connection-pool domain regexes break)

1 participant