Skip to content

[api][java] Validate Java YAML resource types - #1453

Open
da-daken wants to merge 2 commits into
apache:mainfrom
da-daken:codex/fix-java-yaml-decision-model-type
Open

da-daken wants to merge 2 commits into
apache:mainfrom
da-daken:codex/fix-java-yaml-decision-model-type

Conversation

@da-daken

@da-daken da-daken commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue: #1452

Purpose of change

The Java YAML loader only checked supported resource kinds for type: python. The type: java branch passed every kind through, so a Python-only section such as mcp_servers could become a Java descriptor whose class was the unresolved short alias. That failed later during resource construction instead of during YAML loading.

YamlLoader.buildDescriptor now selects an explicit supported-kind set for both languages. Decision models stay in the Java set because they support custom Java implementations; Python-only YAML sections are rejected on the Java path.

Runtime flow:

  1. buildDescriptor reads type, defaulting to Python.
  2. It selects the supported-kind set for that language.
  3. An unsupported kind raises IllegalArgumentException with the language and resource kind.
  4. Supported declarations continue through the existing alias resolution and descriptor construction.

Behavioral Semantics

Interaction decisions

Declaration Result
mcp_servers with type: java Rejected during YAML loading
decision_model_setups with type: java and a custom Java class Java descriptor retained
decision_model_connections with type: java and a custom Java class Java descriptor retained
chat_model_*, embedding_model_*, vector_stores, model_routers with type: java Existing behavior unchanged
type: python declarations Existing supported-kind validation unchanged

Behavioral contracts

  1. A Python-only YAML section with type: java fails during loading with type='java' is not supported for <resource kind>.
  2. Both decision-model sections remain in the Java supported set and load fully-qualified custom Java implementations.
  3. Python declarations retain their existing supported-kind contract.

Failure behavior

Unsupported language/resource-kind combinations raise IllegalArgumentException from YamlLoader.buildDescriptor. This prevents an unresolved short alias from surviving as a Java class name and failing later. A fully-qualified class that is absent from the runtime classpath still fails when the resource is constructed, because the loader does not load classes merely to validate YAML.

Tests

Contract Tests
Java declarations reject a Python-only resource kind YamlLoaderBuildAgentsTest (MCP coverage)
Both decision-model sections keep Java support through buildAgents(Path) YamlLoaderBuildAgentsTest.decisionModelJavaDeclarationsLoadCustomImplementations
Java decision descriptors remain constructible at the helper boundary YamlLoaderBuildersTest.descriptorJavaSupportsCustomDecisionImplementations
Existing YAML behavior stays intact YAML loader, sub-agent, router, and alias tests

Coverage by risk: the tests exercise the descriptor helper and both decision-model sections through buildAgents(Path). Not verified: constructing a custom Java decision model from the YAML result; programmatic decision-model registration is covered by AgentPlanDeclareDecisionModelTest.

Targeted tests: 81 passed. Full API module: 944 tests, 0 failures, 16 skipped. Spotless passed using JDK 11.

API

No public API signature changes. The observable behavior is earlier rejection of invalid type: java declarations for Python-only resource kinds.

Documentation

  • doc-needed
  • doc-not-needed
  • doc-included

The behavior agrees with the existing YAML language-support table.

Was this patch authored or co-authored using generative AI tooling?

  • Yes
  • No

Generated-by: OpenAI Codex (GPT-5.1)

The Java YAML loader now validates both descriptor languages against an explicit supported resource-kind set. This rejects type=java for Python-only decision-model resources at load time instead of producing an invalid Java descriptor.

Generated-by: OpenAI Codex (GPT-5.1)
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs fixVersion/1.0.0 The feature or bug should be implemented/fixed in the 1.0.0 version. priority/major Default priority of the PR or issue. labels Nov 25, 2026
@da-daken da-daken changed the title [api][java] Reject Java decision-model YAML resources [api][java] Reject Python-only decision aliases in Java YAML Nov 25, 2026
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs and removed doc-not-needed Your PR changes do not impact docs labels Nov 25, 2026
Decision models have Java extension points, so type=java remains valid for both decision-model sections. Replace the language-only rejection with coverage for custom Java implementations.

Generated-by: OpenAI Codex (GPT-5.1)
@da-daken
da-daken force-pushed the codex/fix-java-yaml-decision-model-type branch from 56faf0d to f827662 Compare November 25, 2026 11:09
@da-daken da-daken changed the title [api][java] Reject Python-only decision aliases in Java YAML [api][java] Validate Java YAML resource types Nov 25, 2026
@github-actions github-actions Bot added doc-not-needed Your PR changes do not impact docs and removed doc-not-needed Your PR changes do not impact docs labels Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs fixVersion/1.0.0 The feature or bug should be implemented/fixed in the 1.0.0 version. priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant