Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat([issue-2952]): surface HF gated-repo/auth failures actionably in the renderer

[._.]/ Adam Eivya7f0c446ac91
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index b18d5bf2fe..6aea1ba336 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -8,6 +8,7 @@
- **[issue-2953] Pick a source image and preview a mesh on the 3D page** — the **3D** page is now a generation workspace, not just an install screen. Search your render history for a source image with the built-in picker — or open one straight from any render's **Send to 3D** action, which now lands here — then choose which image-to-3D model to use. Your source image and model choice live in the page's address, so a specific setup is shareable and reload-safe. When a mesh is produced it renders in an interactive `.glb` viewer you can orbit and zoom, with a one-click **Download .glb**. The **Generate 3D** button stays disabled with a plain reason (pick an image, install the model, or "generation lands with the on-device runner") until the render pipeline is wired up next.
- **[issue-2972] Deleting a 3D render mid-generation now stops it and cleans up** — if you delete an image-to-3D record while its mesh is still rendering, PortOS now terminates the on-device render process right away (instead of letting it keep burning your GPU to finish a model you no longer want) and removes the orphaned `.glb` it may have left on disk. Deleting a record that isn't rendering is unchanged.
- **[issue-2952] On-device TRELLIS.2 renders now land correctly and show real progress** — validated the runner against the real TRELLIS.2 `generate.py` on Apple Silicon and fixed two things that showed up only on a live render: the finished `.glb` now saves to the exact spot PortOS serves it from (previously it could land one folder over and show as missing), and the progress bar now moves through the real stages of a render — loading the model, sampling, decoding the mesh, baking textures, exporting — instead of sitting at 0% for the whole multi-minute render and then jumping to done.
+- **[issue-2952] Clear message when a 3D render needs Hugging Face access** — TRELLIS.2 pulls a gated model from Hugging Face the first time it runs, so a render on a machine that isn't signed in to Hugging Face used to fail with an unhelpful "generate exited 1". PortOS now recognizes that specific failure and tells you exactly what to do: accept the gated model's terms and sign in to Hugging Face (set an `HF_TOKEN` or run `huggingface-cli login`), then try again.
## Internal
diff --git a/server/services/imageTo3d/trellis2.js b/server/services/imageTo3d/trellis2.js
index 95e16edee0..7f7679cfc7 100644
--- a/server/services/imageTo3d/trellis2.js
+++ b/server/services/imageTo3d/trellis2.js
@@ -315,6 +315,43 @@ export function installTrellis2({
return { promise, kill };
}
+/**
+ * Signatures of a Hugging Face **auth / gated-repo** failure during a render. The
+ * TRELLIS.2 pipeline pulls a gated dependency model (`facebook/dinov3-…`) at load
+ * time; on a host with no `HF_TOKEN` (or one whose account hasn't accepted that
+ * model's terms) `from_pretrained` raises `GatedRepoError` / a `401` and the render
+ * exits non-zero — which is otherwise indistinguishable from a real crash. Detecting
+ * it lets the runner surface an actionable "authenticate with Hugging Face" message
+ * instead of a bare "exited 1". Confirmed against the real failure during #2952
+ * on-device validation (gated `facebook/dinov3-vitl16-pretrain-lvd1689m`).
+ */
+const HF_AUTH_ERROR_RE = new RegExp(
+ [
+ 'GatedRepoError', 'gated repo', 'access to model .* is restricted',
+ 'You must have access to it', 'must be authenticated to access',
+ 'Please log in', 'Access to model .* is restricted', 'RepositoryNotFoundError',
+ '401 Client Error', 'Invalid user token', 'Repo .* is gated',
+ ].join('|'),
+ 'i',
+);
+
+/**
+ * Whether a captured chunk of render output looks like a Hugging Face auth/gated-repo
+ * failure (see `HF_AUTH_ERROR_RE`). Exported so the runner and tests share one
+ * classification.
+ * @param {string} text
+ * @returns {boolean}
+ */
+export function isHfAuthError(text) {
+ return HF_AUTH_ERROR_RE.test(String(text ?? ''));
+}
+
+/** Human-actionable guidance for the gated-dependency failure above. */
+const HF_AUTH_HELP = 'TRELLIS.2 could not download a gated model dependency from '
+ + 'Hugging Face. Accept the terms for facebook/dinov3-vitl16-pretrain-lvd1689m at '
+ + 'https://huggingface.co/facebook/dinov3-vitl16-pretrain-lvd1689m, then authenticate '
+ + '(set HF_TOKEN or run `huggingface-cli login`) and try again.';
+
/**
* Run a single image→GLB generation. The one real-subprocess boundary — GUARDED:
* throws `TRELLIS2_NOT_INSTALLED` unless the model is present, so it can never run
@@ -350,8 +387,12 @@ export function runTrellis2Generate({
// throw into the request lifecycle (CLAUDE.md child-process exception).
const child = spawnImpl(command, args, { cwd: trellis2Root(base) });
let assetPath = outputPath || null;
+ // Retain a bounded tail of combined output so a non-zero exit can be classified
+ // (HF auth/gated-repo vs. a real crash) — the clue is in the text, not the code.
+ let outputTail = '';
const promise = new Promise((resolve, reject) => {
const ingest = (buf) => {
+ outputTail = `${outputTail}${buf}`.slice(-4000);
for (const line of String(buf).split('\n')) {
const frame = parseGenerateProgress(line);
if (!frame) continue;
@@ -367,6 +408,14 @@ export function runTrellis2Generate({
resolve({ assetPath });
return;
}
+ // A gated-dependency / HF-auth failure is a user-fixable setup problem, not a
+ // crash — surface it as such with actionable guidance instead of "exited N".
+ if (code !== 0 && isHfAuthError(outputTail)) {
+ const err = new Error(HF_AUTH_HELP);
+ err.code = 'TRELLIS2_HF_AUTH_REQUIRED';
+ reject(err);
+ return;
+ }
const err = new Error(
code === 0 ? 'TRELLIS.2 finished but produced no .glb' : `TRELLIS.2 generate exited ${code}`,
);
diff --git a/server/services/imageTo3d/trellis2.test.js b/server/services/imageTo3d/trellis2.test.js
index f934682737..0930497c1f 100644
--- a/server/services/imageTo3d/trellis2.test.js
+++ b/server/services/imageTo3d/trellis2.test.js
@@ -13,6 +13,7 @@ import {
runTrellis2Generate,
installTrellis2,
isTransientInstallError,
+ isHfAuthError,
} from './trellis2.js';
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
@@ -212,6 +213,27 @@ describe('runTrellis2Generate', () => {
await expect(promise).rejects.toMatchObject({ code: 'TRELLIS2_GENERATE_FAILED' });
});
+ it('classifies a gated-repo / HF-auth failure as a distinct, actionable error', async () => {
+ // The real #2952 on-device failure: the pipeline pulls a gated dependency model
+ // and, with no HF_TOKEN, from_pretrained raises GatedRepoError → non-zero exit.
+ const child = makeChild();
+ const { promise } = runTrellis2Generate({
+ imagePath: 'a.png',
+ outputPath: '/out/a.glb',
+ base: BASE,
+ exists: installed,
+ spawnImpl: () => child,
+ });
+ child.stderr.emit('data',
+ 'huggingface_hub.errors.GatedRepoError: 401 Client Error. '
+ + 'Access to model facebook/dinov3-vitl16-pretrain-lvd1689m is restricted.\n');
+ child.emit('close', 1);
+ await expect(promise).rejects.toMatchObject({
+ code: 'TRELLIS2_HF_AUTH_REQUIRED',
+ message: expect.stringMatching(/hugging face/i),
+ });
+ });
+
it('rejects when it exits 0 but never reported a .glb', async () => {
const child = makeChild();
const { promise } = runTrellis2Generate({
@@ -276,6 +298,29 @@ describe('isTransientInstallError', () => {
});
});
+describe('isHfAuthError', () => {
+ it.each([
+ 'huggingface_hub.errors.GatedRepoError: 401 Client Error.',
+ 'Access to model facebook/dinov3-vitl16-pretrain-lvd1689m is restricted.',
+ 'You must have access to it and be authenticated to access it. Please log in.',
+ 'OSError: You are trying to access a gated repo.',
+ 'Invalid user token.',
+ ])('flags an HF auth / gated-repo failure: %s', (line) => {
+ expect(isHfAuthError(line)).toBe(true);
+ });
+
+ it.each([
+ 'RuntimeError: MPS backend out of memory',
+ 'IndexError: max(): Expected reduction dim 0 to have non-zero size',
+ 'AssertionError: BVH needs at least 8 triangles, got 0',
+ '',
+ null,
+ undefined,
+ ])('does NOT flag a non-auth failure: %s', (line) => {
+ expect(isHfAuthError(line)).toBe(false);
+ });
+});
+
describe('installTrellis2', () => {
const makeChild = () => {
const child = new EventEmitter();