Skip to content

Fixed async form loading#602

Merged
cristian-tamblay merged 1 commit into
developfrom
fix/form
May 6, 2026
Merged

Fixed async form loading#602
cristian-tamblay merged 1 commit into
developfrom
fix/form

Conversation

@cristian-tamblay
Copy link
Copy Markdown
Member

Summary

Fixes a bug where parameters from a previously-selected model leaked into a newly-added model when configuring an experiment, causing training to fail with schema validation errors (e.g. DummyClassifier receiving n_estimators, learning_rate). The bug only manifested in production builds because dev mode (HMR + Strict Mode) was masking the stale state.


Type of Change

  • Backend change
  • Frontend change
  • CI / Workflow change
  • Build / Packaging change
  • Bug fix
  • Documentation

Changes (by file)

  • DashAI/front/src/hooks/useSchema.js: Reset the cached model state to null at the start of the effect when modelName changes. Previously the hook kept the old schema while fetching the new one, so defaultValues returned the previous model's params until the async fetch completed — if the user clicked "Add" quickly, those stale params were saved on the new model.
  • DashAI/front/src/components/shared/FormSchemaDialog.jsx: Added key={modelToConfigure} to FormSchemaContainer so the FormSchemaProvider remounts when switching models in the edit dialog (matching the pattern already used in AddModelDialog). Prevents formValues from carrying over between different models.

Testing

  • In a production build, create an experiment with a tabular classification task.
  • Add a model with rich params (e.g. RandomForest), click "Add".
  • Switch the model dropdown to one with different params (e.g. DummyClassifier), click "Add".
  • Open the new model's edit dialog and confirm only its own params are present.
  • Run training — it should not fail with Field required schema validation errors.

Notes

The bug only reproduced in production builds because React Strict Mode and HMR in dev caused enough remounts to mask the stale-state issue. Worth keeping in mind for similar hooks that hold async-fetched state — clearing the cache when the input changes is safer than relying on the consumer to handle the transition.

@cristian-tamblay cristian-tamblay merged commit 23a8b74 into develop May 6, 2026
4 checks passed
@cristian-tamblay cristian-tamblay deleted the fix/form branch May 6, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant