{"record":{"id":"370083a0b29d5f63","repo":"airbnb/epoxy","slug":"you-cannot-call-requestmodelbuild-directly-call-setdata-370083","errorCode":null,"errorMessage":"You cannot call `requestModelBuild` directly. Call `setData` instead to trigger a model refresh with new data.","messagePattern":"You cannot call `requestModelBuild` directly\\. Call `setData` instead to trigger a model refresh with new data\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"epoxy-adapter/src/main/java/com/airbnb/epoxy/Typed3EpoxyController.java","lineNumber":49,"sourceCode":"  }\n\n  /**\n   * Call this with the latest data when you want models to be rebuilt. The data will be passed on\n   * to {@link #buildModels(Object, Object, Object)}\n   */\n  public void setData(T data1, U data2, V data3) {\n    this.data1 = data1;\n    this.data2 = data2;\n    this.data3 = data3;\n    allowModelBuildRequests = true;\n    requestModelBuild();\n    allowModelBuildRequests = false;\n  }\n\n  @Override\n  public final void requestModelBuild() {\n    if (!allowModelBuildRequests) {\n      throw new IllegalStateException(\n          \"You cannot call `requestModelBuild` directly. Call `setData` instead to trigger a \"\n              + \"model refresh with new data.\");\n    }\n    super.requestModelBuild();\n  }\n\n  @Override\n  public void moveModel(int fromPosition, int toPosition) {\n    allowModelBuildRequests = true;\n    super.moveModel(fromPosition, toPosition);\n    allowModelBuildRequests = false;\n  }\n\n  @Override\n  public void requestDelayedModelBuild(int delayMs) {\n    if (!allowModelBuildRequests) {\n      throw new IllegalStateException(\n          \"You cannot call `requestModelBuild` directly. Call `setData` instead to trigger a \"","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/airbnb/epoxy/blob/e45bd3a61fe3a1f130e184f5b8dcf172ab99025a/epoxy-adapter/src/main/java/com/airbnb/epoxy/Typed3EpoxyController.java#L31-L67","documentation":"Typed3EpoxyController finalizes `requestModelBuild()` and throws `IllegalStateException` unless `allowModelBuildRequests` is true, which happens only inside `setData(data1, data2, data3)`. The controller insists all rebuilds come with new data so its three typed data fields stay consistent with the built models.","triggerScenarios":"Calling `controller.requestModelBuild()` directly from app code — e.g. after mutating one of the three data objects in place, or after a network callback completes, instead of calling `setData` again.","commonSituations":"Migrating from `EpoxyController` to a Typed3 controller while keeping old `requestModelBuild()` refresh calls; refreshing after a partial data update without re-supplying all three data objects; calling refresh from a presenter/viewmodel that holds stale data.","solutions":["Call `controller.setData(newData1, newData2, newData3)` with the current values for all three parameters.","Store the latest data in the owning screen and re-submit it via `setData` whenever a rebuild is needed.","If manual rebuild control is required, switch to base `EpoxyController` instead of a Typed variant.","Make the subclass's `buildModels(data1, data2, data3)` a pure function of its arguments so re-submitting data is safe."],"exampleFix":"// before\ncontroller.requestModelBuild(); // IllegalStateException\n\n// after\ncontroller.setData(latestData1, latestData2, latestData3);","handlingStrategy":"validation","validationCode":"// Typed3EpoxyController: refresh only via setData\ncontroller.setData(newData1, newData2, newData3);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always re-supply all three data values when refreshing a Typed3 controller.","Treat data passed to setData as immutable snapshots; rebuild and resubmit on change.","Update any migrated refresh code from requestModelBuild to setData."],"tags":["android","epoxy","lifecycle","api-misuse"],"backgroundTag":"unsupported-operation","analyzedSha":"e45bd3a61fe3a1f130e184f5b8dcf172ab99025a","analyzedAt":"2026-09-13T03:24:16.052Z","contentChangedAt":"2026-09-13T03:24:16.052Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}