fix: validate OpenAIPrompt Java post-processing options#2576
fix: validate OpenAIPrompt Java post-processing options#2576fallintoplace wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Hey @fallintoplace 👋! We use semantic commit messages to streamline the release process. Examples of commit messages with semantic prefixes:
To test your commit locally, please follow our guild on building from source. |
There was a problem hiding this comment.
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
HashMapoverload to delegate to the ScalaMap[String, String]overload (restoring validation + mode inference parity). - Add isolated unit tests covering CSV inference from
delimiter, regex requiringregexGroup, 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). |
Problem
The
java.util.HashMapoverload ofOpenAIPrompt.setPostProcessingOptionswrites the parameter directly, bypassing the inference and validation performed by the ScalaMapoverload. Java and Py4J callers can therefore create configurations that Scala callers cannot, including regex options withoutregexGroupand unsupported option maps. The overload also fails to inferpostProcessingfrom valid options.Changes
Testing
cognitive/testOnly com.microsoft.azure.synapse.ml.services.openai.OpenAIPromptParamsSuite(3 tests passed)cognitive/Test/scalastyle(0 findings)cognitive/Compile/scalastyle(0 findings)