Route all HTTP calls through SiloClient instead of direct urllib.request #30
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Several HTTP calls in the FreeCAD layer bypass the
SiloClientfrom thesilo-clientsubmodule and useurllib.requestdirectly. This creates inconsistency in authentication handling, SSL configuration, error handling, and timeout management. Thesilo-clientsubmodule exists specifically to be the single HTTP abstraction — all requests should go through it.Direct urllib.request Calls That Bypass SiloClient
1. Server readiness check — silo_commands.py:~179-200
Manually constructs SSL context and sets timeout against
{base_url}/ready. No auth header.2. Schema properties fetch — schema_form.py:~273-280
Fetches
{api_url}/schemas/kindred-rd/properties?category={cat}with manually built auth headers, SSL context, and timeout. Also hardcodes the schema name.3. Part number generation — schema_form.py:~293-301
POSTs to
{api_url}/generate-part-numberwith manually built auth headers, SSL context, and timeout. Hardcodes the schema name.4. SSE event stream — silo_commands.py:~2438-2445
Connects to
{api_url}/eventswithAccept: text/event-streamheader. Manually builds auth headers, SSL context, and timeout (90s).5. Diagnostics — silo_commands.py:~3904-3970
Tests
/health,/ready,/auth/me, and/eventsendpoints all with directurllib.requestcalls, each with manually configured SSL and timeouts.Problems
SiloClientchanges its auth header format (e.g. adding request signing), the direct calls will not pick it up._get_ssl_context()— a parallel implementation to whateverSiloClientdoes internally.SiloClientpresumably has unified error handling (retries, status code mapping, logging). Direct calls do ad-hoc try/except with varying behavior.SiloClientdoes not expose these endpoints yet, they should be added to it — that is the point of the shared client.Proposed Solution
Add missing methods to silo-client (in the submodule repo)
The following methods should be added to
SiloClient:check_ready()— GET /readyget_schema_properties(schema, category)— GET /schemas/{schema}/propertiesgenerate_part_number(schema, category)— POST /generate-part-numberopen_event_stream()— GET /events (returns raw response for SSE parsing)check_health()— GET /healthcheck_auth()— GET /auth/meUpdate FreeCAD layer to use them
_fetch_server_mode()should call_client.check_ready()_SchemaPropertiesWorkershould call_client.get_schema_properties(schema, category)_PartNumberWorkershould call_client.generate_part_number(schema, category)SiloEventListenershould call_client.open_event_stream()_DiagWorkershould call_client.check_health(),_client.check_ready(),_client.check_auth()Remove from FreeCAD layer
_get_ssl_context()helper (delegate to client)urllib.requestimports and usage insilo_commands.pyandschema_form.pyschema_form.pyAcceptance Criteria
urllib.requestcalls remain in the FreeCAD layerSiloClientmethods