{"record":{"id":"1d359ff428abee5e","repo":"emberjs/ember.js","slug":"you-accessed-this-access-from-a-function-passe","errorCode":null,"errorMessage":"You accessed `this${access}` from a function passed to the ${source}, but the function itself was not bound to a valid `this` context. Consider updating to use a bound function (for instance, use an arrow function, `() => {}`).","messagePattern":"You accessed `this(.+?)` from a function passed to the (.+?), but the function itself was not bound to a valid `this` context\\. Consider updating to use a bound function \\(for instance, use an arrow function, `\\(\\) => (.+?)`\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@glimmer/debug-util/lib/untouchable-this.ts","lineNumber":12,"sourceCode":"import { DEBUG } from '@glimmer/env';\n/* eslint-disable @typescript-eslint/no-empty-object-type */\nexport default function buildUntouchableThis(source: string): null | object {\n  let context: null | object = null;\n  if (DEBUG) {\n    let assertOnProperty = (property: string | number | symbol) => {\n      let access =\n        typeof property === 'symbol' || typeof property === 'number'\n          ? `[${String(property)}]`\n          : `.${property}`;\n\n      throw new Error(\n        `You accessed \\`this${access}\\` from a function passed to the ${source}, but the function itself was not bound to a valid \\`this\\` context. Consider updating to use a bound function (for instance, use an arrow function, \\`() => {}\\`).`\n      );\n    };\n\n    context = new Proxy(\n      {},\n      {\n        get(_target: {}, property: string | symbol) {\n          assertOnProperty(property);\n        },\n\n        set(_target: {}, property: string | symbol) {\n          assertOnProperty(property);\n\n          return false;\n        },\n\n        has(_target: {}, property: string | symbol) {","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/@glimmer/debug-util/lib/untouchable-this.ts#L1-L30","documentation":"untouchable-this creates a Proxy used as the `this` context for unbound functions passed to certain APIs (e.g. computed-like callbacks). Any property access, set, or `has` check on that proxy throws this error, telling the developer their function isn't bound to a real object and probably relies on implicit `this` (a classic function syntax pitfall).","triggerScenarios":"Passing a non-arrow `function () { return this.someProp; }` to an API wrapped by untouchable-this, then the function reads/writes `this.x` or checks `in this` — the proxy's get/set/has traps fire assertOnProperty.","commonSituations":"Refactoring from Ember object model where `this` was the component; using plain functions where arrow functions are expected; copy-pasted legacy helper code that mutates `this`.","solutions":["Convert the callback to an arrow function and reference captured variables instead of `this`","Bind the function explicitly to the intended context if `this` is genuinely required","Rewrite the logic to take dependencies as parameters rather than instance state","Search the callback for `this.` usages and eliminate them"],"exampleFix":"// before\nsomeApi(function () {\n  return this.value;\n});\n// after\nsomeApi(() => {\n  return externalValue;\n});","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function usesThis(fn) { return /\\bthis\\b/.test(Function.prototype.toString.call(fn)) && !/^(?:\\(|function\\s*\\([^)]*\\)\\s*=>)/.test(Function.prototype.toString.call(fn).trim()); }","tryCatchPattern":"try {\n  someApi(callback);\n} catch (e) {\n  if (String(e.message).includes('not bound to a valid `this` context')) {\n    console.error('Convert the callback to an arrow function and avoid `this`');\n  } else { throw e; }\n}","preventionTips":["Always use arrow functions for callbacks that shouldn't rely on `this`","Never read/write `this.x` inside functions passed to framework APIs","Grep new callbacks for `this.` usage before committing"],"tags":["this","binding","proxy","arrow-function","glimmer"],"backgroundTag":"unbound-this-in-callback","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}