{"record":{"id":"7db142e43948d7fa","repo":"remix-run/remix","slug":"cannot-install-context-property-formattedproperty","errorCode":null,"errorMessage":"Cannot install context property {formattedProperty} because this context key already uses {JSON.stringify(existingProperty)}.","messagePattern":"Cannot install context property (.+?) because this context key already uses (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/fetch-router/src/lib/request-context.ts","lineNumber":307,"sourceCode":"    }\n\n    this.#contextMap.set(key, value)\n  }\n\n  #installContextProperty(key: object, property: string): void {\n    if (typeof property !== 'string') {\n      throw new Error('Context property name must be a string.')\n    }\n\n    if (property.length === 0) {\n      throw new Error('Cannot install an empty context property name.')\n    }\n\n    let formattedProperty = JSON.stringify(property)\n\n    let existingProperty = this.#contextPropertyKeys.get(key)\n    if (existingProperty != null && existingProperty !== property) {\n      throw new Error(\n        `Cannot install context property ${formattedProperty} because this context key already uses ${JSON.stringify(existingProperty)}.`,\n      )\n    }\n\n    let existingKey = this.#contextProperties.get(property)\n    if (existingKey != null) {\n      if (existingKey !== key) {\n        throw new Error(\n          `Cannot install context property ${formattedProperty} because another context key already uses it.`,\n        )\n      }\n\n      return\n    }\n\n    if (property in this) {\n      throw new Error(\n        `Cannot install context property ${formattedProperty} because it already exists on RequestContext.`,","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/fetch-router/src/lib/request-context.ts#L289-L325","documentation":"Each context key object can only be associated with one property name. This error fires when you call ctx.set with the same key object but a different property name than a previous call in the same process/context.","triggerScenarios":"Two middleware files both do ctx.set(sessionKey, x, { property: 'session' }) and later ctx.set(sessionKey, y, { property: 'auth' }) using the same imported key symbol.","commonSituations":"Copy-pasting middleware and renaming the property; refactoring that changes the property string while the shared key module still exports the old usage.","solutions":["Use one property name per context key consistently across the app","Export the key and its property name as a pair from a single module","Rename all call sites together when changing a property name"],"exampleFix":"// before\n// a.ts\nctx.set(sessionKey, s, { property: 'session' })\n// b.ts\nctx.set(sessionKey, s, { property: 'auth' })\n// after\n// context/session.ts\nexport const sessionProperty = 'session'\n// both files use { property: sessionProperty }","handlingStrategy":"validation","validationCode":"const existing = contextPropertyKeys.get(key)\nif (existing != null && existing !== property) throw new Error('key/property mismatch')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export key + property name pairs from one module","Rename all call sites atomically when changing a property name"],"tags":["request-context","fetch-router","middleware"],"backgroundTag":"invalid-context-property","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}