You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix JS client private-Space connections (hf_token alias) and replace raw TypeErrors/unhandled rejections with clear errors (#13657)
* Fix JS client private-Space auth and error handling (hf_token alias, no more raw 'map' TypeErrors / unhandled rejections)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Address Copilot review: trim space_id, slash-tolerant named endpoint lookup, queue flag from skip_queue
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* chore: trigger CI
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Fix private Space connections and error handling in the JS client: accept the deprecated `hf_token` option as an alias for `token`, raise clear errors when a Space is private or missing, tolerate malformed `/info` payloads instead of crashing with "Cannot read properties of undefined (reading 'map')", and make `predict()` reject with real `Error` objects instead of plain status objects that surface as unhandled promise rejections.
Copy file name to clipboardExpand all lines: client/js/src/constants.ts
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,16 @@ export const UNAUTHORIZED_MSG = "Not authorized to access this space. ";
35
35
exportconstINVALID_CREDENTIALS_MSG="Invalid credentials. Could not login. ";
36
36
exportconstMISSING_CREDENTIALS_MSG=
37
37
"Login credentials are required to access this space.";
38
+
exportconstPRIVATE_SPACE_MSG=
39
+
"Could not access this app (received a 401 response). If it is a private Hugging Face Space, pass a valid Hugging Face token to the `token` option of `Client.connect`. You can generate a token at https://huggingface.co/settings/tokens.";
`Space "${space}" could not be accessed (received a ${status} response from the Hugging Face API). `+
42
+
"Check that the Space name is spelled correctly and that the Space exists. If the Space is private, "+
43
+
"pass a valid Hugging Face token to the `token` option of `Client.connect`. You can generate a token at https://huggingface.co/settings/tokens.";
44
+
exportconstNO_API_INFO_MSG=
45
+
"No API information is available for this app. This can happen when the app's `/info` endpoint cannot be reached, or when the app is running a legacy version of Gradio that is not supported by this client. ";
46
+
exportconstWS_PROTOCOL_MSG=
47
+
"This app appears to be running a legacy version of Gradio (3.x or earlier) that communicates over WebSockets, which is not supported by this version of @gradio/client. Please upgrade the app to a newer version of Gradio, or connect to it with @gradio/client version 0.x.";
38
48
exportconstNODEJS_FS_ERROR_MSG=
39
49
"File system access is only available in Node.js environments";
40
50
exportconstROOT_URL_ERROR_MSG="Root URL not found in client config";
0 commit comments