Skip to content

fix(install): preserve curated displayName on AgentProfile + AgentInstallation - #412

Closed
lilyshen0722 wants to merge 1 commit into
mainfrom
fix/agentprofile-displayname-on-install
Closed

lilyshen0722 wants to merge 1 commit into
mainfrom
fix/agentprofile-displayname-on-install

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Summary

  • Closes the install-path equivalent of PR fix(registry): intro post preserves curated displayName (#62 follow-up) #408 — that fix preserved curated displayName on the intro-post path but missed the install-time write to AgentProfile.name.
  • Resolution order now: explicit req.body.displayName → existing User.botMetadata.displayName for the same (agentName, instanceId) → registry default (e.g. "Cuz 🦞" / "Codex").
  • Both write seams (AgentInstallation.install + AgentProfile.findOneAndUpdate) read the same resolved value, so they can't drift.

Repro (from 2026-05-20 smoke test)

Installed six pre-existing dev-agent identities (openclaw:theo/nova/pixel/aria/ops + codex:cody) into a fresh pod via POST /api/registry/install:

{ agentName: "openclaw", instanceId: "aria", podId: "...", version: "1.0.0", scopes: [...] }

Before: AgentInstallation.displayName = "Cuz 🦞", AgentProfile.name = "Cuz 🦞" for all five openclaw agents. Member list rendered "Cuz" everywhere even though User.botMetadata.displayName was "Aria"/"Nova"/etc.
After: both seams write "Aria" (etc.) via the lookup.

Why the V2 member list shows "Cuz"

AgentProfile.name is the per-pod display layer read FIRST by the inspector (per feedback-displayname-role-leak-three-sources). User-row fixes alone aren't enough — every pod-scoped render layer downstream reads AgentProfile.

Test plan

  • New regression test backend/__tests__/service/install.preserves-displayname.test.js covers 3 cases:
    • existing curated identity beats registry default (the main bug)
    • explicit displayName in body beats both
    • registry default still wins when no curated identity exists (fresh install)
  • CI green (Test & Coverage, Service Tests, CodeQL, Chart Lint)
  • Manual verification on dev once deployed: install one openclaw agent into a fresh test pod → member list shows curated name, not "Cuz"

🤖 Generated with Claude Code

…tallation

PR #408 fixed the displayName-clobber on the intro-post path; this is the
matching fix for the install-path itself. Surfaced 2026-05-20 in a fresh
smoke pod: installing six existing dev-agent identities (openclaw:theo/
nova/pixel/aria/ops + codex:cody) wrote the registry-default ("Cuz 🦞"
for openclaw, "Codex" for codex) into BOTH AgentInstallation.displayName
AND AgentProfile.name. The V2 inspector member list reads AgentProfile
FIRST, so every member rendered as "Cuz" even though the underlying
User row had the right botMetadata.displayName.

Fix: before writing either row, look up the existing User row for the
SAME (agentName, instanceId) and prefer its botMetadata.displayName.
Resolution order: explicit caller intent (req.body.displayName) → existing
curated identity → registry default. The User-row lookup is the only
load-bearing add; both call sites then read the resolved value.

Regression test covers three cases: existing curated identity beats the
registry default, explicit displayName beats both, and the registry
default still wins when no curated identity exists (fresh install).
@samxu01 samxu01 closed this in 2df5954 May 21, 2026
samxu01 pushed a commit that referenced this pull request May 22, 2026
…#424)

* fix(install): enrich displayName-lookup log with agentName/instanceId

Code-reviewer follow-up on PR #412. The two displayName-lookup catch
branches in install.ts both log a bare Mongoose error message with no
hint about WHICH agent the lookup was attempting. An operator
diagnosing 'wrong displayName on reinstall' has to cross-reference
timestamps to figure out the install path.

Append `${agent.agentName}:${normalizedInstanceId}` to both log lines:
  - the install-path lookup (line ~284)
  - the intro-path lookup (line ~420)

No behavioral change — strictly diagnostic enrichment.

Co-Authored-By: Lily Shen <[email protected]>

* fix(install): use structured log args to satisfy CodeQL js/format-string-injection

CodeQL flagged the template-literal log lines (`[install] displayName lookup
failed for ${agent.agentName}:${normalizedInstanceId}`) as
format-string-injection: agent.agentName + normalizedInstanceId both
trace back to req.body and end up in the format-string slot.

Same diagnostic payload, just shaped as a structured second arg:

  console.warn('[install] displayName lookup failed', {
    agent: agent.agentName,
    instance: normalizedInstanceId,
    error: (lookupErr as Error).message,
  });

CodeQL doesn't flag user-tainted values in non-format-string slots.

Co-Authored-By: Lily Shen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant