Cursor Agent commited on
Commit
cbae1bb
·
1 Parent(s): 39d06f7

Deploy viewer for DynamicIntelligence/humanoid-robots-training-dataset

Browse files
src/app/[org]/[dataset]/[episode]/fetch-data.ts CHANGED
@@ -34,8 +34,22 @@ export async function getEpisodeData(
34
  } else {
35
  return await getEpisodeDataV2(repoId, version, info, episodeId);
36
  }
37
- } catch (err) {
38
  console.error("Error loading episode data:", err);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  throw err;
40
  }
41
  }
 
34
  } else {
35
  return await getEpisodeDataV2(repoId, version, info, episodeId);
36
  }
37
+ } catch (err: any) {
38
  console.error("Error loading episode data:", err);
39
+
40
+ // Provide helpful error message for 401 errors (gated/private datasets)
41
+ if (err?.message?.includes('401') || err?.message?.includes('Unauthorized')) {
42
+ throw new Error(
43
+ `401 Unauthorized: Cannot access dataset "${repoId}".\n\n` +
44
+ `This dataset is GATED (restricted access).\n\n` +
45
+ `SOLUTION:\n` +
46
+ `1. Go to: https://huggingface.co/datasets/${repoId}/settings\n` +
47
+ `2. Set visibility to PUBLIC\n` +
48
+ `3. Disable "Gated" option if present\n\n` +
49
+ `OR: Grant the HF_TOKEN access to this gated dataset.`
50
+ );
51
+ }
52
+
53
  throw err;
54
  }
55
  }
src/app/api/hf-proxy/route.ts CHANGED
@@ -80,6 +80,20 @@ async function handleRequest(request: NextRequest, method: 'GET' | 'HEAD') {
80
  if (!response.ok) {
81
  // Return error with status code
82
  const errorText = await response.text().catch(() => 'Unknown error');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  return NextResponse.json(
84
  { error: `Failed to fetch: ${response.status} ${response.statusText}`, details: errorText },
85
  { status: response.status }
 
80
  if (!response.ok) {
81
  // Return error with status code
82
  const errorText = await response.text().catch(() => 'Unknown error');
83
+
84
+ // Log detailed error for debugging
85
+ console.error(`Proxy fetch failed: ${response.status} ${response.statusText}`);
86
+ console.error(`URL: ${url}`);
87
+ console.error(`Token present: ${!!token}`);
88
+ console.error(`Token length: ${token ? token.length : 0}`);
89
+ if (response.status === 401) {
90
+ console.error('401 Unauthorized - Possible causes:');
91
+ console.error(' 1. Token has no READ permissions');
92
+ console.error(' 2. Dataset is gated and token/user has no access');
93
+ console.error(' 3. Token is invalid or expired');
94
+ console.error(` 4. Token used: ${token ? token.substring(0, 10) + '...' : 'NONE'}`);
95
+ }
96
+
97
  return NextResponse.json(
98
  { error: `Failed to fetch: ${response.status} ${response.statusText}`, details: errorText },
99
  { status: response.status }
src/utils/versionUtils.ts CHANGED
@@ -48,8 +48,33 @@ export async function getDatasetInfo(repoId: string): Promise<DatasetInfo> {
48
  clearTimeout(timeoutId);
49
 
50
  if (!response.ok) {
51
- const errorData = await response.json().catch(() => ({}));
52
- throw new Error(errorData.error || `Failed to fetch dataset info: ${response.status}`);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
  const data = await response.json();
 
48
  clearTimeout(timeoutId);
49
 
50
  if (!response.ok) {
51
+ // Try to get error details
52
+ let errorText = '';
53
+ try {
54
+ const errorData = await response.json();
55
+ errorText = errorData.error || errorData.details || JSON.stringify(errorData);
56
+ } catch {
57
+ errorText = await response.text().catch(() => `Status: ${response.status} ${response.statusText}`);
58
+ }
59
+
60
+ // Provide helpful error message
61
+ if (response.status === 404) {
62
+ throw new Error(
63
+ `Dataset ${repoId} not found (404). ` +
64
+ `This usually means the dataset is PRIVATE and the HF_TOKEN has no access. ` +
65
+ `URL tried: ${testUrl}. ` +
66
+ `Error: ${errorText}`
67
+ );
68
+ } else if (response.status === 401) {
69
+ throw new Error(
70
+ `Unauthorized access to dataset ${repoId} (401). ` +
71
+ `The HF_TOKEN in the Space needs access to this private dataset. ` +
72
+ `Go to dataset settings → Gated user access → Add access for the token account. ` +
73
+ `Error: ${errorText}`
74
+ );
75
+ } else {
76
+ throw new Error(`Failed to fetch dataset info: ${response.status} ${response.statusText}. ${errorText}`);
77
+ }
78
  }
79
 
80
  const data = await response.json();