deepmodeling / deepmodeling/dpgui
[Code scan] Block JSON export when required fields are invalid
- Dominant language
- Vue
- Stars
- 9
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
This issue was found during a Codex global code scan of the repository.
Baseline commit: e3c5b38a99eb7ab778b5d8c68a5ed4ddf6cf91b3
Problem
The Save JSON button calls `to_json()` directly. Vuetify field rules can show validation errors, but export is not gated on validation state. Empty required values are silently converted into defaults by `dvalue()`.
Code references:
https://github.com/deepmodeling/dpgui/blob/e3c5b38a99eb7ab778b5d8c68a5ed4ddf6cf91b3/src/components/dargs/DargsInput.vue#L27-L28
https://github.com/deepmodeling/dpgui/blob/e3c5b38a99eb7ab778b5d8c68a5ed4ddf6cf91b3/src/components/dargs/DargsItem.vue#L329-L345
Relevant snippet:
```js
if (!this.value) return [];
```
```js
if (!this.value) {
if (this.select_type == "str") return "";
else return 0;
}
```
Impact
Users can export JSON even when required fields are empty or invalid. The exported file can contain `[]`, `""`, or `0` values that were never intentionally supplied.
Suggested fix
Wrap the generated controls in a `v-form`, validate before `to_json()`, and avoid substituting empty required fields with default-looking values during export.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.