{"record":{"id":"54d2f30e185530d0","repo":"HeyPuter/puter","slug":"conflict-54d2f3","errorCode":"conflict","errorMessage":"An app with this name already exists","messagePattern":"An app with this name already exists","errorType":"http","errorClass":"HttpError","httpStatus":409,"severity":"warning","filePath":"src/backend/drivers/apps/AppDriver.js","lineNumber":475,"sourceCode":"                object,\n                options: undefined,\n                user: actor.user,\n                sourceAppUid: app.uid,\n                excludeAppId: app.id,\n            });\n            if (joinedApp) {\n                return joinedApp;\n            }\n            await this.#ensureIndexUrlNotAlreadyInUse({\n                indexUrl: fields.index_url,\n                excludeAppId: app.id,\n            });\n        }\n\n        // Name conflict check (only if name is changing)\n        if (fields.name && fields.name !== app.name) {\n            if (await this.appStore.existsByName(fields.name)) {\n                throw new HttpError(\n                    409,\n                    'An app with this name already exists',\n                    { legacyCode: 'conflict' },\n                );\n            }\n        }\n\n        const filetypes = fields.filetype_associations;\n        delete fields.filetype_associations;\n\n        const updated = await this.appStore.update(app.id, fields);\n        if (filetypes !== undefined) {\n            await this.appStore.setFiletypeAssociations(app.id, filetypes);\n        }\n\n        this.#emitAppChanged({ app: updated, old_app: app, action: 'updated' });\n        if (fields.name && fields.name !== app.name) {\n            this.#emitAppRename({","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/HeyPuter/puter/blob/908ec23eda38526170322c3edf71ba45ecb1ca95/src/backend/drivers/apps/AppDriver.js#L457-L493","documentation":"Thrown during an app update when the requested new name is already taken by another app. The driver only runs this check when `name` is both provided and actually different from the current app name, querying `appStore.existsByName`. It returns HTTP 409 with legacyCode `conflict`.","triggerScenarios":"Calling the app update/upsert driver method with `object.name` set to a value already owned by another app (different uid). Example: `driver.update({ uid, object: { name: 'taken-name' } })` where `taken-name` exists. Triggers only when `fields.name && fields.name !== app.name` resolves true.","commonSituations":"Renaming an app in the Dev Center to a name another user or another of your own apps already holds; importing/deploying an app whose name collides with a built-in or pre-existing app; CI test fixtures that reuse a hardcoded app name without teardown.","solutions":["Choose a unique name; prefix with your username or a slug to avoid collisions.","Before renaming, check availability via the app lookup/name-resolution endpoint (`appStore.getByName`).","If you own the colliding app, delete or rename the other app first.","Handle the 409 gracefully and prompt the end user for a different name."],"exampleFix":"// before\ndriver.update({ uid, object: { name: 'myapp' } }); // may 409\n\n// after\nconst existing = await appStore.getByName('myapp');\nif (existing && existing.uid !== uid) {\n  throw new Error('Name taken, pick another');\n}\nawait driver.update({ uid, object: { name: 'myapp' } });","handlingStrategy":"validation","validationCode":"// Check name availability before the update\nconst taken = await appStore.getByName(newName);\nif (taken && taken.uid !== appUid) {\n  throw new Error(`App name '${newName}' is taken`);\n}\nawait driver.update({ uid: appUid, object: { name: newName } });","typeGuard":"/** @returns {boolean} name looks unique (caller must confirm against store) */\nfunction isValidAppName(name) {\n  return typeof name === 'string' && name.trim().length > 0 && name.trim().length <= 64;\n}","tryCatchPattern":"try {\n  await driver.update({ uid, object: { name } });\n} catch (e) {\n  if (e.code === 'conflict') { /* prompt user for a new name */ return; }\n  throw e;\n}","preventionTips":["Namespace app names with a user/org prefix to avoid collisions.","Pre-check name availability before surfacing a rename to the user.","Clean up test fixtures between runs so stale names don't collide."],"tags":["apps","conflict","validation","driver"],"backgroundTag":null,"analyzedSha":"908ec23eda38526170322c3edf71ba45ecb1ca95","analyzedAt":"2026-08-12T20:53:15.911Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}