Repository navigation
Commit 3e9717e
fix: give PlatformAPIClient the contract APIDeploymentsClient already has
Six findings from the review on this PR. Five were real contract gaps and one
was a missed export; all are pinned by tests that fail when the fix is reverted.
**The body is read as JSON, not through the generated model.** This is the one
that mattered. `sync_detailed` reaches `_parse_response`, which does
`PlatformKeyError.from_dict(response.json())` on a 401 with no guard: a gateway
answering 401 with HTML raises `JSONDecodeError`, and a DRF-shaped
`{"detail": ...}` raises `KeyError: 'message'` -- both out of the generated
parser, before this facade sees the response. So a rejected key crashed instead
of being reported. The request is now issued from the generated `_get_kwargs`
and the body read through `APIDeploymentsClient._read_body`, which is exactly
why that helper exists.
This is the same defect class as the `_error_text` fix in the previous commit. I
fixed the half where reporting a refusal crashed and missed the half where
building the model crashed first.
**Transport failures are translated.** The class called `sync_detailed`
directly, so an unreachable host raised raw `httpx.ConnectError` -- contradicting
the module docstring this PR added, which promises the `requests` exception types
callers catch. It now goes through `_send`, like every deployment-key request.
**The credential is read per request.** `AuthenticatedClient` bakes its auth
header on first use, so a key assigned after the transport was built kept
sending the old one. `_send` sets the header per call.
**`close`, `__enter__` and `__exit__`** -- pooled connections had nothing to
release them, and the CLI builds one client per job.
**Re-exported from the package root**, so it is reachable as
`unstract.api_deployments.PlatformAPIClient` rather than only from the private
module.
Also corrected the `_error_text` comment from the previous commit: it described
the platform facade raising AttributeError, which is no longer a path that
exists now that both facades hand it an httpx response.
438 tests pass, up from 430. Five mutations killed: unguarded `response.json()`,
dropping the transport translation, capturing the key with the transport,
neutering `close`, and removing the re-export. The generated tree is untouched,
so `sdk-drift` is unaffected.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y7U4ggFchu91zKYcRxFRNZ1 parent db20a25 commit 3e9717e
3 files changed
Lines changed: 174 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
953 | 953 | | |
954 | 954 | | |
955 | 955 | | |
956 | | - | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
957 | 961 | | |
958 | 962 | | |
959 | 963 | | |
| |||
969 | 973 | | |
970 | 974 | | |
971 | 975 | | |
972 | | - | |
973 | | - | |
| 976 | + | |
| 977 | + | |
974 | 978 | | |
975 | 979 | | |
976 | 980 | | |
| |||
1014 | 1018 | | |
1015 | 1019 | | |
1016 | 1020 | | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
1017 | 1024 | | |
1018 | 1025 | | |
1019 | 1026 | | |
| |||
1028 | 1035 | | |
1029 | 1036 | | |
1030 | 1037 | | |
1031 | | - | |
1032 | | - | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
1033 | 1074 | | |
1034 | | - | |
1035 | | - | |
1036 | | - | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
1037 | 1082 | | |
| 1083 | + | |
1038 | 1084 | | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | | - | |
1045 | 1085 | | |
1046 | 1086 | | |
1047 | 1087 | | |
1048 | 1088 | | |
1049 | | - | |
| 1089 | + | |
1050 | 1090 | | |
1051 | | - | |
| 1091 | + | |
1052 | 1092 | | |
1053 | | - | |
| 1093 | + | |
1054 | 1094 | | |
1055 | 1095 | | |
1056 | 1096 | | |
| |||
1064 | 1104 | | |
1065 | 1105 | | |
1066 | 1106 | | |
1067 | | - | |
1068 | | - | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
1069 | 1110 | | |
1070 | 1111 | | |
1071 | 1112 | | |
| |||
1099 | 1140 | | |
1100 | 1141 | | |
1101 | 1142 | | |
1102 | | - | |
| 1143 | + | |
1103 | 1144 | | |
1104 | | - | |
1105 | 1145 | | |
1106 | 1146 | | |
1107 | 1147 | | |
1108 | 1148 | | |
1109 | 1149 | | |
1110 | 1150 | | |
1111 | 1151 | | |
1112 | | - | |
| 1152 | + | |
| 1153 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2025 | 2025 | | |
2026 | 2026 | | |
2027 | 2027 | | |
2028 | | - | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
2029 | 2032 | | |
2030 | 2033 | | |
| 2034 | + | |
| 2035 | + | |
2031 | 2036 | | |
2032 | 2037 | | |
2033 | 2038 | | |
| |||
2060 | 2065 | | |
2061 | 2066 | | |
2062 | 2067 | | |
2063 | | - | |
2064 | | - | |
2065 | | - | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
2066 | 2071 | | |
2067 | 2072 | | |
2068 | 2073 | | |
| |||
2091 | 2096 | | |
2092 | 2097 | | |
2093 | 2098 | | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
0 commit comments