Commit e5dffc6
fix: Firebase token refresh, create_model notes mismatch (#202)
* fix: correct Permit2 allowance threshold from 10% to 100% (closes #188)
The allowance guard used amount_base * 0.1 (10%) which allowed
x402 payments to proceed when only 10% of the required OPG was
approved. This caused downstream payment failures when the
allowance was between 10-99% of the required amount.
Fix: compare allowance_before against the full amount_base so
the approval step is skipped only when allowance is already
sufficient.
* fix: ModelHub Firebase token refresh + create_model version/notes fix (closes #164, #157)
Bug 1 — Firebase idToken expiry (closes #164):
ModelHub cached self._hub_user at login time and never refreshed
the idToken. Firebase tokens expire after 3600 s, so any API call
made more than ~1 hour after construction silently fails with 401.
Fix: add _get_auth_token() which checks time.time() against a stored
expiry and calls firebase_app.auth().refresh(refreshToken) when the
token is within _TOKEN_REFRESH_MARGIN_SEC (60 s) of expiry. All
methods now call _get_auth_token() instead of reading idToken directly.
Bug 2 — create_model passes version label as notes (closes #157):
create_model(model_name, model_desc, version='1.00') called
self.create_version(model_name, version) which mapped the version
string '1.00' to the positional parameter of create_version.
The server ignores that field as a version specifier and auto-assigns
its own version string, so the argument was silently discarded.
Fix: call self.create_version(created_name, notes=f'Initial version {version}')
to make the intent explicit, and rename the local variable from
model_name to created_name to avoid shadowing the input parameter.
* fix: cast idToken to str to satisfy mypy [no-any-return] on line 83
firebase is an untyped package (type: ignore[import-untyped]), so
self._hub_user['idToken'] resolves to Any. Since _get_auth_token()
is declared -> str, mypy raised:
error: Returning Any from function declared to return 'str' [no-any-return]
Fix: wrap with str() cast which is always safe since Firebase idTokens
are JWT strings.
* Update src/opengradient/client/model_hub.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: kukac <adambalogh@users.noreply.github.com>
---------
Signed-off-by: kukac <adambalogh@users.noreply.github.com>
Co-authored-by: kukac <adambalogh@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 7eaf127 commit e5dffc6
1 file changed
Lines changed: 58 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
37 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
41 | 52 | | |
42 | 53 | | |
43 | 54 | | |
44 | 55 | | |
45 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
46 | 84 | | |
47 | 85 | | |
48 | 86 | | |
| |||
51 | 89 | | |
52 | 90 | | |
53 | 91 | | |
54 | | - | |
| 92 | + | |
| 93 | + | |
55 | 94 | | |
56 | 95 | | |
57 | | - | |
| 96 | + | |
58 | 97 | | |
59 | 98 | | |
60 | | - | |
| 99 | + | |
61 | 100 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | 101 | | |
66 | | - | |
| 102 | + | |
67 | 103 | | |
68 | 104 | | |
69 | 105 | | |
| |||
74 | 110 | | |
75 | 111 | | |
76 | 112 | | |
77 | | - | |
78 | | - | |
| 113 | + | |
| 114 | + | |
79 | 115 | | |
80 | 116 | | |
81 | | - | |
82 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
83 | 123 | | |
84 | | - | |
| 124 | + | |
85 | 125 | | |
86 | 126 | | |
87 | 127 | | |
| |||
98 | 138 | | |
99 | 139 | | |
100 | 140 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | 141 | | |
105 | | - | |
| 142 | + | |
106 | 143 | | |
107 | 144 | | |
108 | 145 | | |
| |||
136 | 173 | | |
137 | 174 | | |
138 | 175 | | |
139 | | - | |
| 176 | + | |
140 | 177 | | |
141 | 178 | | |
142 | 179 | | |
143 | 180 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | 181 | | |
149 | 182 | | |
150 | 183 | | |
151 | 184 | | |
152 | | - | |
| 185 | + | |
153 | 186 | | |
154 | 187 | | |
155 | 188 | | |
| |||
191 | 224 | | |
192 | 225 | | |
193 | 226 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | 227 | | |
198 | | - | |
| 228 | + | |
199 | 229 | | |
200 | 230 | | |
201 | 231 | | |
| |||
0 commit comments