Skip to content

fix(a2a-server,core-tool): harden host fallback and guard schema definition conflicts#1191

Open
RuleViz wants to merge 1 commit intoagentscope-ai:mainfrom
RuleViz:fix/a2a-host-fallback-schema-defs
Open

fix(a2a-server,core-tool): harden host fallback and guard schema definition conflicts#1191
RuleViz wants to merge 1 commit intoagentscope-ai:mainfrom
RuleViz:fix/a2a-host-fallback-schema-defs

Conversation

@RuleViz
Copy link
Copy Markdown

@RuleViz RuleViz commented Apr 11, 2026

This PR fixes two reliability issues across A2A server setup and tool schema generation.

  1. In A2A deployment properties, host resolution now falls back to localhost when local IP lookup throws a SocketException, and logs a warning instead of leaving host as null.
  2. In tool parameter schema generation, $defs hoisting now detects conflicting definitions for the same key and throws an explicit exception instead of silently overriding previous entries.

The change includes regression tests for both cases:

  • deployment host fallback on local IP resolution failure
  • $defs merge behavior for both conflicting and equivalent definitions

- fallback deployment host to localhost when local IP lookup fails\n- detect conflicting schema definitions during defs hoisting\n- add regression tests for fallback and conflict/equivalent defs behavior\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@RuleViz RuleViz requested review from a team and Copilot April 11, 2026 08:11
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 11, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves reliability in A2A server deployment defaults and tool JSON Schema generation by adding safer fallbacks and fail-fast behavior for schema definition conflicts.

Changes:

  • Fall back to localhost when local IP resolution throws SocketException, and warn with the exception.
  • Detect and reject conflicting $defs/definitions entries during schema hoisting instead of silently overwriting.
  • Add regression tests covering both the host fallback behavior and $defs conflict/equivalence handling.

Reviewed changes

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

File Description
agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-server/src/main/java/io/agentscope/core/a2a/server/transport/DeploymentProperties.java Adds localhost fallback + warning log when local IP lookup fails.
agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-server/src/test/java/io/agentscope/core/a2a/server/transport/DeploymentPropertiesTest.java Updates expectation to assert localhost on local IP lookup failure.
agentscope-core/src/main/java/io/agentscope/core/tool/ToolSchemaGenerator.java Guards $defs hoisting against conflicting definitions using equality checks + fail-fast exception.
agentscope-core/src/test/java/io/agentscope/core/tool/ToolSchemaGeneratorTest.java Adds unit tests for conflicting vs equivalent $defs merges via reflective invocation.

} catch (SocketException exception) {
host = DEFAULT_HOST;
log.warn(
"Failed to resolve local IP address, fallback to default host: {}",
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

Log message grammar: "fallback" is a noun; as a verb it should be "fall back" (e.g., "...; falling back to default host"). Adjusting this improves readability/searchability in logs.

Suggested change
"Failed to resolve local IP address, fallback to default host: {}",
"Failed to resolve local IP address, falling back to default host: {}",

Copilot uses AI. Check for mistakes.
}
if (!Objects.equals(existingDef, incomingDef)) {
throw new IllegalStateException(
"Conflicting schema definition found for key: " + defKey);
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

The IllegalStateException message will be useful for debugging schema generation failures, but it could be more actionable by including whether the conflict came from "$defs" vs "definitions" and a short hint that this can be caused by simple-name collisions under PLAIN_DEFINITION_KEYS. Consider enriching the message accordingly.

Suggested change
"Conflicting schema definition found for key: " + defKey);
"Conflicting schema definition found for key '"
+ defKey
+ "' while hoisting from '"
+ key
+ "'. This can be caused by simple-name collisions when using plain definition keys.");

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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