BabylonJS/Babylon.js · error

No avatar found for forum user "${username}"

Error message

No avatar found for forum user "${username}"

What it means

This build-time script resolves a forum user's avatar by fetching https://forum.babylonjs.com/u/<username>.json and reading user.avatar_template. It throws when the Discourse API response contains no avatar_template, i.e. the username does not exist or the profile exposes no avatar.

Source

Thrown at packages/dev/inspector-v2/scripts/makeAvatar.mjs:65

                return;
            }
            if (res.statusCode !== 200) {
                reject(new Error(`HTTP ${res.statusCode} for ${url}`));
                return;
            }
            const chunks = [];
            res.on("data", (chunk) => chunks.push(chunk));
            res.on("end", () => resolve(Buffer.concat(chunks)));
            res.on("error", reject);
        }).on("error", reject);
    });
}

async function fetchForumAvatarUrl(username, size = 96) {
    const userJson = JSON.parse((await fetchUrl(`https://forum.babylonjs.com/u/${username}.json`)).toString("utf-8"));
    const avatarTemplate = userJson.user?.avatar_template;
    if (!avatarTemplate) {
        throw new Error(`No avatar found for forum user "${username}"`);
    }
    const relativePath = avatarTemplate.replace("{size}", String(size));
    return `https://forum.babylonjs.com${relativePath}`;
}

const isUrl = /^https?:\/\//i.test(inputPath);
const isFilePath = !isUrl && (inputPath.includes("/") || inputPath.includes("\\") || existsSync(resolve(inputPath)));

let inputBuffer;
if (isUrl) {
    inputBuffer = await fetchUrl(inputPath);
} else if (isFilePath) {
    inputBuffer = await readFile(resolve(inputPath));
} else {
    // Treat as a Babylon.js forum username
    const avatarUrl = await fetchForumAvatarUrl(inputPath);
    inputBuffer = await fetchUrl(avatarUrl);
}

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Verify the username exists by visiting https://forum.babylonjs.com/u/<username> and correct the spelling in the input.
  2. If the account was renamed/deleted, update the contributor data to the current username or remove the entry.
  3. Check the raw JSON endpoint (/u/<username>.json) to confirm avatar_template is present; if API shape changed, update the parsing logic.
  4. Add retry/backoff if the forum API rate-limits the request in CI.

Example fix

// before
node makeAvatar.mjs jonathanibany  // typo'd username
// after
node makeAvatar.mjs JCPalmer  // verified existing forum username
// or fetch the profile first to confirm:
// curl https://forum.babylonjs.com/u/<username>.json
Defensive patterns

Strategy: retry

Validate before calling

async function forumUserExists(username: string): Promise<boolean> {
  const res = await fetch(`https://forum.babylonjs.com/u/${encodeURIComponent(username)}.json`);
  if (!res.ok) return false;
  const json = await res.json();
  return !!json?.user?.avatar_template;
}

Type guard

function hasAvatarTemplate(u: unknown): u is { user: { avatar_template: string } } {
  return typeof (u as any)?.user?.avatar_template === "string";
}

Try / catch

try {
  const url = await fetchForumAvatarUrl(username);
} catch (e) {
  if (e instanceof Error && e.message.includes("No avatar found for forum user")) {
    console.warn(`Skipping ${username}: no forum avatar; using default avatar.`);
  } else throw e;
}

Prevention

When it happens

Trigger: Running makeAvatar.mjs with a username that has no forum account, a typo'd handle, a deleted/suspended account, or a forum API response lacking user.avatar_template (private or restricted profile).

Common situations: Contributor avatar generation in CI where a listed username was changed or deleted; typos in the contributors list; forum rate-limiting or API shape changes returning unexpected JSON.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/31fceacf41e32409. Report an issue: GitHub.