Skip to content

path() silently coerces invalid runtime boolean option values #383

@dahlia

Description

@dahlia

Summary

path() relies on typed boolean options such as mustExist, mustNotExist, and allowCreate, but it does not validate them at runtime. If malformed truthy values like "no" reach the parser through an untyped path, JavaScript truthiness silently changes validation behavior.

Reproduction

import { path } from "@optique/run";

console.log(path({ mustExist: "no" as never }).parse("/tmp"));
console.log(path({ mustNotExist: "no" as never }).parse("/tmp"));
console.log(path({ allowCreate: "no" as never }).parse("nonexistent/file.txt"));

Current behavior:

  • mustExist: "no" still behaves like mustExist: true
  • mustNotExist: "no" still behaves like mustNotExist: true
  • allowCreate: "no" still enables parent-directory validation as if allowCreate were true

Expected behavior

Invalid runtime option types should be rejected up front instead of being silently coerced by JavaScript truthiness.

Actual behavior

The parser accepts malformed runtime values and quietly changes behavior.

Notes

This is a configuration-validation bug in the same family as the runtime option coercion issues already visible in hostname(), domain(), float(), and the IP parsers.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions