Skip to content

fix: validate OpenAIPrompt Java post-processing options#2576

Open
fallintoplace wants to merge 1 commit into
microsoft:masterfrom
fallintoplace:fix/openai-prompt-java-options
Open

fix: validate OpenAIPrompt Java post-processing options#2576
fallintoplace wants to merge 1 commit into
microsoft:masterfrom
fallintoplace:fix/openai-prompt-java-options

Conversation

@fallintoplace

Copy link
Copy Markdown

Problem

The java.util.HashMap overload of OpenAIPrompt.setPostProcessingOptions writes the parameter directly, bypassing the inference and validation performed by the Scala Map overload. Java and Py4J callers can therefore create configurations that Scala callers cannot, including regex options without regexGroup and unsupported option maps. The overload also fails to infer postProcessing from valid options.

Changes

  • delegate the Java overload to the Scala overload after converting the map
  • add isolated unit coverage for CSV mode inference, required regex groups, and invalid option parity between Java and Scala maps

Testing

  • cognitive/testOnly com.microsoft.azure.synapse.ml.services.openai.OpenAIPromptParamsSuite (3 tests passed)
  • cognitive/Test/scalastyle (0 findings)
  • cognitive/Compile/scalastyle (0 findings)

Copilot AI review requested due to automatic review settings July 26, 2026 02:16
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions

Copy link
Copy Markdown

Hey @fallintoplace 👋!
Thank you so much for contributing to our repository 🙌.
Someone from SynapseML Team will be reviewing this pull request soon.

We use semantic commit messages to streamline the release process.
Before your pull request can be merged, you should make sure your first commit and PR title start with a semantic prefix.
This helps us to create release messages and credit you for your hard work!

Examples of commit messages with semantic prefixes:

  • fix: Fix LightGBM crashes with empty partitions
  • feat: Make HTTP on Spark back-offs configurable
  • docs: Update Spark Serving usage
  • build: Add codecov support
  • perf: improve LightGBM memory usage
  • refactor: make python code generation rely on classes
  • style: Remove nulls from CNTKModel
  • test: Add test coverage for CNTKModel

To test your commit locally, please follow our guild on building from source.
Check out the developer guide for additional guidance on testing your change.

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.

Pull request overview

This PR fixes inconsistent validation/inference behavior for OpenAIPrompt.setPostProcessingOptions when called from Java/Py4J by delegating the java.util.HashMap overload to the existing Scala Map overload, ensuring both call paths apply the same validation rules and post-processing inference.

Changes:

  • Update the Java HashMap overload to delegate to the Scala Map[String, String] overload (restoring validation + mode inference parity).
  • Add isolated unit tests covering CSV inference from delimiter, regex requiring regexGroup, and Java/Scala invalid-option parity.

Reviewed changes

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

File Description
cognitive/src/main/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIPrompt.scala Delegate Java HashMap overload to Scala overload so Java/Py4J callers get the same validation and inference as Scala callers.
cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIPromptParamsSuite.scala Add targeted tests validating Java overload behavior (mode inference + validation parity).

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