{"record":{"id":"795367a60348a031","repo":"discourse/discourse","slug":"formkit-the-data-property-expects-a-pojo","errorCode":null,"errorMessage":"[FormKit]: the @data property expects a POJO.","messagePattern":"\\[FormKit\\]: the @data property expects a POJO\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/discourse/app/form-kit/lib/fk-form-data.js","lineNumber":51,"sourceCode":"  @tracked patches = [];\n\n  /**\n   * The inverse patches to be applied, useful for rollback.\n   * @type {Array}\n   */\n  @tracked inversePatches = [];\n\n  /**\n   * Creates an instance of Changeset.\n   * @param {any} data - The initial data.\n   */\n  constructor(data) {\n    try {\n      this.data = produce(data, () => {});\n      this.draftData = produce(data, () => {});\n    } catch (e) {\n      if (e.message.includes(\"[Immer]\")) {\n        throw new Error(\"[FormKit]: the @data property expects a POJO.\", {\n          cause: e,\n        });\n      }\n    }\n  }\n\n  /**\n   * Checks if the changeset is valid.\n   * @return {boolean} True if there are no errors.\n   */\n  get isValid() {\n    return Object.keys(this.errors).length === 0;\n  }\n\n  /**\n   * Checks if the changeset is invalid.\n   * @return {boolean} True if there are errors.\n   */","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/discourse/discourse/blob/1b2d7253e854205d2c95c80b2c6a1cdd42e45059/frontend/discourse/app/form-kit/lib/fk-form-data.js#L33-L69","documentation":"A type-coercion guard in the FormKit changeset constructor: the @data passed to the form is not a POJO, so Immer's `produce` rejected it (message containing \"[Immer]\") and the original cause is rethrown wrapped. The faulty input is the non-plain-object value bound to `<form.Form @data>` (e.g. an Ember object, class instance, or undefined-derived value).","triggerScenarios":"Thrown at frontend/discourse/app/form-kit/lib/fk-form-data.js:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a plain JavaScript object as @data, e.g. `{ ...model }` instead of the model instance","Convert arrays/Map/Set or Ember proxies to POJOs before handing them to the form","Inspect `e.cause` for the underlying Immer error if the data looks like a POJO"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1b2d7253e854205d2c95c80b2c6a1cdd42e45059","analyzedAt":"2026-08-26T03:11:08.302Z","contentChangedAt":"2026-08-26T03:11:08.302Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}