Skip to content

Kotlin sdk catalog uri scheme#1398

Merged
jgindin merged 2 commits into
google:mainfrom
jgindin:kotlin-sdk-catalog-uri-scheme
May 19, 2026
Merged

Kotlin sdk catalog uri scheme#1398
jgindin merged 2 commits into
google:mainfrom
jgindin:kotlin-sdk-catalog-uri-scheme

Conversation

@jgindin
Copy link
Copy Markdown
Collaborator

@jgindin jgindin commented May 11, 2026

Description

Implement equivalent transparent file:// URI parsing support in CatalogConfig.fromPath and BasicCatalog.getConfig. Unsupported schemes are correctly rejected, and robust unit tests are included.

Port of Python SDK commit 90a0a19

Pre-launch Checklist

If you need help, consider asking for advice on the discussion board.

@jgindin jgindin requested a review from nan-yu May 11, 2026 16:26
@jgindin jgindin self-assigned this May 11, 2026
@github-project-automation github-project-automation Bot moved this to Todo in A2UI May 11, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements a streaming parser for A2UI (v0.8 and v0.9), enhances catalog pruning for messages and common types, and improves schema validation with detailed error reporting. New utilities like TopologyAnalyzer and SchemaInspector are introduced to manage component relationships and reachability. Reviewer feedback highlights critical performance bottlenecks in the parser's JSON processing and metadata sniffing, a potential argument swap in the AgentExtension constructor, and robustness issues in URI path resolution.

val objBuffer = jsonBuffer.substring(startIdx)
if (objBuffer.startsWith("{") && objBuffer.endsWith("}")) {
try {
val obj = Json.parseToJsonElement(objBuffer) as? JsonObject
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.

critical

Parsing the entire objBuffer using Json.parseToJsonElement every time a closing brace } is encountered results in $O(N^2)$ complexity relative to the JSON size. For large or deeply nested JSON payloads, this will cause severe performance issues and potential memory pressure.

}

if (braceCount > 0 && char in listOf('"', ':', ',', '}', ']')) {
sniffMetadata()
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.

critical

Calling sniffMetadata() for every punctuation character in the JSON stream is extremely expensive due to the underlying regex searches in getLatestValue. This logic should be optimized to either use a more efficient state machine or to only sniff at specific intervals or boundaries.

Comment on lines +528 to +538
val searchStr = "\"$key\""
while (true) {
idx = jsonBuffer.lastIndexOf(searchStr, idx - 1)
if (idx == -1) return null

val fragment = jsonBuffer.substring(idx)
val match = Regex("\"$key\"\\s*:\\s*\"([^\"]+)\"").find(fragment)
if (match != null && match.range.first == 0) {
return match.groupValues[1]
}
}
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.

high

Creating a new Regex object inside getLatestValue is highly inefficient, especially since this function is called frequently during punctuation sniffing. This will lead to significant performance degradation as the JSON buffer grows.

Comment thread agent_sdks/kotlin/src/main/kotlin/com/google/a2ui/a2a/A2uiA2a.kt
Comment thread agent_sdks/kotlin/src/main/kotlin/com/google/a2ui/core/parser/StreamingParser.kt Outdated
Comment on lines +48 to +51
java.net.URI(catalogPath)
} catch (e: Exception) {
null
}
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.

medium

The java.net.URI constructor is strict and may throw URISyntaxException for valid local file paths that contain characters like spaces or colons (common on Windows). While the try-catch handles the exception, it's safer to check if the string looks like a URI before attempting to parse it, or use File(catalogPath).toURI() if a local path is intended.

@jgindin jgindin force-pushed the kotlin-sdk-catalog-uri-scheme branch 3 times, most recently from 2579b16 to ed9072f Compare May 12, 2026 15:52
Copy link
Copy Markdown
Collaborator

@nan-yu nan-yu left a comment

Choose a reason for hiding this comment

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

Looks good to me on the URI scheme support in CatalogConfig commit.

@jgindin jgindin force-pushed the kotlin-sdk-catalog-uri-scheme branch 9 times, most recently from 9b8c82c to ec6f28b Compare May 19, 2026 16:40
@jgindin jgindin requested a review from nan-yu May 19, 2026 16:40
@jgindin jgindin force-pushed the kotlin-sdk-catalog-uri-scheme branch from ec6f28b to 2593ca4 Compare May 19, 2026 19:57
jgindin added 2 commits May 19, 2026 16:02
Implements custom JSON-path validation error string construction for
v0.9 payloads in Kotlin, matching Python exactly. Validates messages
individually via sub-validators and iterates component arrays to
construct precise path prefixes.

Port of Python SDK commit 15ee789

� Conflicts:
�	agent_sdks/kotlin/src/main/kotlin/com/google/a2ui/core/parser/StreamingParser.kt
�	agent_sdks/kotlin/src/main/kotlin/com/google/a2ui/core/schema/Validator.kt
Implement equivalent transparent file:// URI parsing support in
CatalogConfig.fromPath and BasicCatalog.getConfig. Unsupported schemes
are correctly rejected, and robust unit tests are included.

Port of Python SDK commit 90a0a19
@jgindin jgindin force-pushed the kotlin-sdk-catalog-uri-scheme branch from 2593ca4 to fd68b17 Compare May 19, 2026 20:03
@jgindin jgindin merged commit f64ccb6 into google:main May 19, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in A2UI May 19, 2026
@jgindin jgindin deleted the kotlin-sdk-catalog-uri-scheme branch May 19, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants