kubeflow / kubeflow/kale

bug(frontend): DefaultState global object is mutated at runtime, causing shared state between notebooks

Open Beginner friendly
#643 6 comments 0 reactions 0 assignees View on GitHub
2.x candidate area/frontend bug good first issue
Dominant language
Python
Stars
703
Forks
161
Avg merge
6d 3h
Merged PRs (30d)
10

Description

### Description

`DefaultState` in `LeftPanel.tsx` [reference](https://github.com/kubeflow/kale/blob/9d52f720320fc466783ac3105f7fdf5fecfe009a/labextension/src/widgets/LeftPanel.tsx#L85) is an exported `const` object used as initial state. But inside `setNotebookPanel()` [reference](https://github.com/kubeflow/kale/blob/9d52f720320fc466783ac3105f7fdf5fecfe009a/labextension/src/widgets/LeftPanel.tsx#L263), the code directly mutates it:

```typescript
DefaultState.metadata.base_image = baseImage;
```
Since the component initializes with state = DefaultState [reference](https://github.com/kubeflow/kale/blob/9d52f720320fc466783ac3105f7fdf5fecfe009a/labextension/src/widgets/LeftPanel.tsx#L110), the component state and the global share the same object reference. Mutating the global also silently mutates
this.state bypassing React.

Problems

1. React state bypassed: Direct mutation without setState, no re-render triggered
2. Reset doesn't reset: resetState() spreads the mutated global, so "defaults" carry previous values
3. State leaks between notebooks: Notebooks with no metadata inherit mutated values from previously opened notebooks

Suggested fix

Store the detected base image in component state instead of mutating the global. Break the shared reference on initialization.

---
Impacted by this bug? Give it a 👍.

Contributor guide

Open the contributing guide

Research direction

Start in labextension/src/widgets/LeftPanel.tsx, reading DefaultState initialization, setNotebookPanel(), and resetState(). Trace how base_image is detected and how state is initialized or reset. Done means notebook panels no longer share mutable defaults, resetState() restores clean defaults, and the detected base image updates through component state.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.