Skip to content

VArg silently returns undefined for non-JSON string arguments #289

@xsynaptic

Description

@xsynaptic

Environment

I'm working with v4.0.0-alpha.1.

Reproduction

import { VArg } from "ipx/handlers/utils";

// These return undefined instead of the expected string value
VArg("450x300")  // undefined (expected: "450x300")
VArg("cover")    // undefined (expected: "cover")
VArg("ff0000")   // undefined (expected: "ff0000")

// JSON primitives work fine
VArg("123")      // 123
VArg("true")     // true

Describe the bug

JSON.parse("450x300") throws SyntaxError. The catch block swallows it and the function ends without returning, so undefined is returned implicitly.

export function VArg(argument: string) {
  if (argument === "Infinity") {
    return Infinity;
  }
  try {
    const val = JSON.parse(argument);
    // ...
  } catch {
    // error swallowed
  }
  // no return → undefined
}

I'll submit a PR with a fix restoring behavior to what it was before destr was removed 🙌

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions