Skip to content

Fix properties template rendering - #265

Open
vondras wants to merge 2 commits into
cyberark:mainfrom
vondras:codex/fix-properties-template-for-java-compatibility
Open

Fix properties template rendering#265
vondras wants to merge 2 commits into
cyberark:mainfrom
vondras:codex/fix-properties-template-for-java-compatibility

Conversation

@vondras

@vondras vondras commented Jun 26, 2026

Copy link
Copy Markdown

Desired Outcome

format: properties should generate Java .properties-compatible output.

Before this change, the properties push-to-file format reused the dotenv template, which rendered values with Go %q quoting. That produced output like:

db.host="myhost.example.com"

Java .properties consumers treat double quotes as literal characters, not delimiters, so applications received "myhost.example.com" instead of myhost.example.com.

The desired outcome is for simple property values to render without introduced quote characters:

db.host=myhost.example.com

while preserving existing behavior for dotenv, bash, json, and yaml formats.

Implemented Changes

This PR adds a dedicated Java properties rendering path instead of reusing dotenvTemplate.

Changes include:

  • Added a propertiesTemplate for format: properties.

  • Updated the standard template map so properties uses propertiesTemplate while continuing to use validatePropertyVarName.

  • Added a propertiesenc template helper for Java properties value escaping.

  • Preserved existing dotenv rendering behavior, including its current quoted value output.

  • Added regression tests covering:

    • simple unquoted properties output
    • aliases with dots
    • literal double quote handling
    • leading spaces
    • backslashes
    • property separator/comment-related characters
    • newlines
    • unchanged dotenv rendering behavior

Reviewers should focus on whether the escaping behavior matches the intended Java properties compatibility contract and whether the scope is appropriate for format: properties.

No screenshots are relevant for this change.

Connected Issue/Story

Resolves #264

CyberArk internal issue ID: N/A - external contribution

Definition of Done

At least 1 todo must be completed in the sections below for the PR to be
merged.

Changelog

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a
    CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code
    changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR
  • A follow-up issue to update official docs has been filed here: [insert issue ID]
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

This PR changes behavior for format: properties to match the documented Java-style properties behavior. As an external contributor, I do not have access to CyberArk PO review; maintainers can route this internally if required.

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

Copilot AI review requested due to automatic review settings June 26, 2026 21:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes format: properties push-to-file output so it is compatible with Java .properties consumers by removing Go %q quoting and adding Java-properties-style escaping for values.

Changes:

  • Switched the properties standard format from reusing the dotenv template to a dedicated propertiesTemplate.
  • Added a propertiesenc template helper to escape property values (e.g., backslashes, newlines, separators).
  • Added/updated tests to ensure properties output is unquoted while dotenv remains Go-quoted.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/pushtofile/standard_templates.go Maps properties format to the new dedicated template instead of dotenv.
pkg/pushtofile/standard_templates_definitions.go Introduces propertiesTemplate using the new propertiesenc helper.
pkg/pushtofile/standard_templates_test.go Updates existing properties expectations and adds regression tests for Java-compatible escaping and unchanged dotenv behavior.
pkg/file_templates/template_functions.go Adds propertiesencTemplateFunc implementation for Java .properties value escaping.
pkg/file_templates/secret_file_templates.go Exposes propertiesenc via the template FuncMap so templates can use it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/file_templates/template_functions.go
Comment on lines +45 to +48
"b64enc": b64encTemplateFunc,
"b64dec": b64decTemplateFunc,
"htmlenc": htmlencTemplateFunc,
"propertiesenc": propertiesencTemplateFunc,
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@micahlee

micahlee commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Hi @vondras, thanks for reporting this and for opening a PR to fix it.

We've pulled it into our internal review and CI process. I'll update this thread when it's merged and when the fix is available here.

Thanks again for the contribution!

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.

format: properties emits quoted values incompatible with Java .properties consumers

3 participants