PEN-110: expose daemon models for distributed onboarding#78
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the public models listing API to include capabilities from active, healthy, and non-stale daemon nodes, and adds automated smoke tests and documentation for self-serve distributed onboarding. The review feedback highlights two key improvements: first, making the list_models API more resilient by gracefully skipping daemon nodes with malformed JSON rather than failing the entire request with a 500 error; second, securing the json_field helper in the smoke test script by passing arguments to Python via sys.argv instead of direct shell variable interpolation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| for (provider_family, model_ids_json) in daemon_rows { | ||
| for model_id in parse_json_vec(&model_ids_json, "daemon_node.model_ids_json")? { | ||
| if !seen_model_ids.insert(model_id.clone()) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
If a single daemon node has corrupted or invalid JSON in model_ids_json, calling list_models will fail the entire request with a 500 Internal Server Error due to the use of the ? operator on parse_json_vec.\n\nTo make the public models listing API more resilient and fault-tolerant, we should log a warning and skip the misconfigured daemon node instead of failing the entire API call.
for (provider_family, model_ids_json) in daemon_rows {\n let model_ids = match parse_json_vec(&model_ids_json, "daemon_node.model_ids_json") {\n Ok(ids) => ids,\n Err(error) => {\n warn!(error = %error, "failed to parse daemon node model IDs, skipping node");\n continue;\n }\n };\n for model_id in model_ids {\n if !seen_model_ids.insert(model_id.clone()) {\n continue;\n }| json_field() { | ||
| python3 -c 'import json,sys; data=json.load(sys.stdin); print(data["'$1'"])' | ||
| } |
There was a problem hiding this comment.
Directly interpolating the shell variable $1 into the Python script string can lead to syntax errors or command injection vulnerabilities if the field name contains special characters.\n\nIt is safer and more robust to pass the field name as a command-line argument to the Python process and access it via sys.argv.
| json_field() { | |
| python3 -c 'import json,sys; data=json.load(sys.stdin); print(data["'$1'"])' | |
| } | |
| json_field() {\n python3 -c 'import json,sys; data=json.load(sys.stdin); print(data[sys.argv[1]])' "$1"\n} |
Co-authored-by: multica-agent <github@multica.ai>
10ac598 to
fbd7c74
Compare
Co-authored-by: multica-agent <github@multica.ai>
Summary
Links
Verification