Skip to content

fix: validate OpenAIPrompt Java post-processing options - #2576

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

fix: validate OpenAIPrompt Java post-processing options#2576
fallintoplace wants to merge 14 commits 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).

ranadeepsingh and others added 2 commits July 30, 2026 21:47
Route generated Python setter and setParams calls through the validated JVM overload, and add Scala, Java, and Py4J regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@codecov-commenter

codecov-commenter commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.14634% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.79%. Comparing base (617ad0f) to head (aedd696).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...l/services/openai/OpenAIPromptPostProcessing.scala 68.65% 21 Missing ⚠️
...napse/ml/services/openai/OpenAIPromptParsers.scala 72.72% 3 Missing ⚠️
...zure/synapse/ml/services/openai/OpenAIPrompt.scala 96.36% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2576      +/-   ##
==========================================
+ Coverage   84.78%   84.79%   +0.01%     
==========================================
  Files         334      337       +3     
  Lines       17806    17944     +138     
  Branches     1623     1669      +46     
==========================================
+ Hits        15097    15216     +119     
- Misses       2709     2728      +19     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Keep generated constructor and explicit empty-map compatibility while routing non-empty post-processing options through JVM validation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

AB#2576

## Summary
Route Scala, Java, and generated Python OpenAIPrompt post-processing
configuration through shared validation while preserving compatible empty-map
and legacy persistence behavior. Add lifecycle regressions and preserve the
complete six-round review record.

## Prompting Intent
Take end-to-end ownership of GitHub PR 2576 after its upstream rebase. Audit
API compatibility, Scala and Python behavior, Py4J, code generation,
serialization, security, and tests through six sequential model review rounds;
fix every finding; validate the final implementation; and push without
rewriting history.

## Linked Sources
- Pull request: microsoft#2576
- Review records: reviews/pr-2576/

## Rationale
Keep business rules on the JVM and expose narrow generated-Python hooks rather
than duplicating validation semantics in hand-written wrappers. Use transient
provenance for explicit-mode intent so historical serialized stages remain
readable without changing public JVM signatures or persisted parameter shapes.
Validate before mutating Python or JVM state so failed setters and setParams
calls remain atomic.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AB#2576

## Summary
Merge the latest remote PR head into the fully reviewed OpenAIPrompt changes so
the branch includes the owner's newest master merge without rewriting either
history.

## Prompting Intent
Take end-to-end ownership of GitHub PR 2576 while verifying the remote head
immediately before every push and never force-pushing or rewriting history.
Reconcile any concurrent upstream movement safely before publishing the
reviewed fixes.

## Linked Sources
- Pull request: microsoft#2576
- Remote head: 1484e0b

## Rationale
Use a normal merge because the PR owner advanced the branch with a new master
merge after review completed. This preserves the remote commit as an ancestor,
keeps the reviewed commit intact, and allows a standard fast-forward push
without force or history replacement.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

AB#2576

## Summary
Remove the concrete test-only OpenAIPrompt subclass that the repository-wide
fuzzing scanner treated as a production pipeline stage. Exercise generated
Python output reflectively on the real stage instead.

## Prompting Intent
Monitor the full Azure validation for GitHub PR 2576, investigate code
failures, fix them without changing public behavior, rerun the exact failing
coverage, and preserve the complete resolution record.

## Linked Sources
- Pull request: microsoft#2576
- Failed Azure build: https://msdata.visualstudio.com/b9b2accc-2d1c-45b3-9d24-0eb5d78cc47f/_build/results?buildId=229226446
- Review record: reviews/pr-2576/task-2576-attempt-1-review-6-gemini-3.6-flash.md

## Rationale
Reflection targets the existing JVM-public codegen method without adding a
second concrete PipelineStage class. This retains the codegen drift regression
while satisfying the repository invariant that every discoverable stage has
fuzzing, serialization, Python, and R coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

ranadeepsingh and others added 2 commits August 4, 2026 00:26
AB#2576

## Summary
Delete the six internal multi-model review Markdown files so they are not
included in the SynapseML pull request.

## Prompting Intent
The engineer requested that review files be removed from the committed change
set because they should not be merged into the repository.

## Linked Sources
- Pull request: microsoft#2576

## Rationale
Keep the implementation, tests, and production-facing history in the PR while
excluding internal review process artifacts that are not repository
deliverables.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AB#2576

## Summary
Merge SynapseML master at 617ad0f into the OpenAIPrompt PR branch without
rewriting published history.

## Prompting Intent
The engineer requested that the PR branch be updated with the latest changes
from master. They selected a normal merge rather than rebasing and
force-pushing the published branch.

## Linked Sources
- Pull request: microsoft#2576
- Master commit: microsoft@617ad0f

## Rationale
Use a merge commit to preserve the existing reviewed branch history and avoid
a force-push. The incoming master changes do not overlap the OpenAIPrompt,
codegen, or associated test files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@ranadeepsingh

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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.

4 participants