{"record":{"id":"be2cd0b1e511c356","repo":"remix-run/remix","slug":"cannot-install-an-empty-context-property-name","errorCode":null,"errorMessage":"Cannot install an empty context property name.","messagePattern":"Cannot install an empty context property name\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/fetch-router/src/lib/request-context.ts","lineNumber":300,"sourceCode":"  set = <key extends object>(\n    key: key,\n    value: ContextValue<key>,\n    options?: { property: string },\n  ): void => {\n    if (options != null) {\n      this.#installContextProperty(key, options.property)\n    }\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      }","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/fetch-router/src/lib/request-context.ts#L282-L318","documentation":"When installing a named context property, an empty string is not a valid property name. This error is thrown from #installContextProperty when property.length === 0.","triggerScenarios":"ctx.set(key, value, { property: '' }), often from a computed name that is undefined-then-stringified, an empty env var, or missing config field.","commonSituations":"Deriving property names from headers/config where the field is absent, producing '' at runtime in some environments only.","solutions":["Default the name to a real string: property: name || 'defaultValue'","Fail fast in config loading when required names are missing","Validate property names before calling ctx.set"],"exampleFix":"// before\nctx.set(key, value, { property: env.USER_PROP })\n// after\nctx.set(key, value, { property: env.USER_PROP || 'user' })","handlingStrategy":"validation","validationCode":"if (!property) throw new TypeError('property name required')","typeGuard":"const isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.length > 0","tryCatchPattern":null,"preventionTips":["Default computed names: name || 'fallback'","Fail config loading early when required names are empty"],"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"}