Skip to content

[Code scan] Block JSON export when required fields are invalid #561

Description

@njzjz

This issue was found during a Codex global code scan of the repository.

Baseline commit: e3c5b38

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:

<v-btn block @click="to_json()">
{{ $t("message.save_json") }}

// textarea -> list
if (!this.value) return [];
return this.value
.trim()
.split("\n")
.map((v) => {
try {
return JSON.parse(v);
} catch (e) {
return v;
}
});
}
} else if (["str", "int", "float"].includes(this.select_type)) {
if (!this.value) {
if (this.select_type == "str") return "";
else return 0;

Relevant snippet:

if (!this.value) return [];
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions