Skip to content

MLE-29419: Hash expression values in URI templates when writing documents - #688

Draft
prgs-rsingh wants to merge 1 commit into
developfrom
feature/mle-29419-uri-template-hash-values
Draft

prgs-rsingh wants to merge 1 commit into
developfrom
feature/mle-29419-uri-template-hash-values

Conversation

@prgs-rsingh

Copy link
Copy Markdown

Summary

Implements MLE-29419: Adds support for hashing expression values resolved from URI templates when writing documents in Flux import and copy commands.

Depends on: marklogic/marklogic-spark-connector#703

Key Changes

  • Added T uriTemplateHashValues() fluent builder method to WriteDocumentsOptions API.
  • Added --uri-template-hash-values CLI option to WriteDocumentParams across all import commands supporting --uri-template, passing Options.WRITE_URI_TEMPLATE_HASH_VALUES = "true" to the Spark connector.
  • Added --output-uri-template-hash-values CLI option and uriTemplateHashValues() method to CopyCommand.CopyWriteDocumentsParams for the copy command.
  • Updated documentation in docs/import/common-import-features.md, docs/import/incremental-write.md, and docs/copy.md with usage instructions, examples, synergy with incremental writes, and the pseudonymization caveat.
  • Added tests in ImportFilesOptionsTest, CopyOptionsTest, and AggregateJsonFilesImporterTest.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

End-to-end behavior depends on an open, currently blocked Spark connector pull request.

2 open findings
What changed in this PR

Adds SHA-256 hashing for URI-template expression values across Flux import and copy APIs.

Changes:

  • Adds CLI and fluent API options for hashed URI-template values.
  • Passes the connector option through import and copy workflows.
  • Adds tests and usage/security documentation.
File Description
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​api/​WriteDocumentsOptions.java Adds the fluent hashing option.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​WriteDocumentParams.java Implements import CLI/API option mapping.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​copy/​CopyCommand.java Implements copy CLI/API option mapping.
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​impl/​importdata/​ImportFilesOptionsTest.java Tests import option mapping and default behavior.
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​impl/​copy/​CopyOptionsTest.java Tests copy option mapping and default behavior.
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​api/​AggregateJsonFilesImporterTest.java Verifies generated hashed URIs.
docs/​import/​common-import-features.md Documents import usage and pseudonymization.
docs/​import/​incremental-write.md Documents incremental-write integration.
docs/​copy.md Documents the copy option.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/copy.md
Similarly, to construct document URIs via a template, use `--output-uri-template`. As of Flux 2.2.0, you can use
`--output-uri-template-hash-values` to hash each resolved expression value in the template using SHA-256 (lowercase hex)
before constructing the document URI. You can also use `--output-uri-template-warn-on-missing-field` to log a warning and
replace missing expressions with a UUID instead of failing.

--uri-template "/employee/{id}/{last_name}.json" --uri-template-hash-values

When specified, every expression in the template is individually replaced by its 64-character lowercase hex digest.
@prgs-rsingh
prgs-rsingh marked this pull request as draft October 13, 2026 11:20
* @return this options instance
* @since 2.2.0
*/
T uriTemplateHashValues();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's inconsistency here with the previous PR for inheriting permissions and collections, as to whether a method for a boolean value accepts an argument or not. I don't think it was 100% consistent before the 2.0 release. I would check all the methods in the API that map to boolean values and see what's most common, and then update either this PR or modify the previous feature to not use a boolean value. Generally, I like not having a boolean when it's a feature that's disabled by default.

This branch has not been deployed

No deployments
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.

3 participants