Kotlin sdk catalog uri scheme#1398
Conversation
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
| } | ||
|
|
||
| if (braceCount > 0 && char in listOf('"', ':', ',', '}', ']')) { | ||
| sniffMetadata() |
There was a problem hiding this comment.
| 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] | ||
| } | ||
| } |
| java.net.URI(catalogPath) | ||
| } catch (e: Exception) { | ||
| null | ||
| } |
There was a problem hiding this comment.
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.
2579b16 to
ed9072f
Compare
nan-yu
left a comment
There was a problem hiding this comment.
Looks good to me on the URI scheme support in CatalogConfig commit.
9b8c82c to
ec6f28b
Compare
ec6f28b to
2593ca4
Compare
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
2593ca4 to
fd68b17
Compare
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.