Skip to content

loggingOptions() does not validate invalid runtime level discriminants #373

@dahlia

Description

@dahlia

Summary

loggingOptions() switches on config.level without a runtime default case, so an unsupported level value arriving through an untyped path leaves levelParser undefined and causes an internal crash during parser construction.

Reproduction

import { loggingOptions } from "@optique/logtape";

loggingOptions({ level: "traceflag" as never });

Current behavior: construction throws TypeError: Cannot read properties of undefined (reading 'priority').

Expected behavior

Unsupported runtime level discriminants should be rejected up front with a clear configuration error.

Actual behavior

The invalid configuration falls through the switch, leaves levelParser undefined, and crashes later when the parser is assembled.

Notes

This is a runtime configuration-validation bug. The TypeScript union prevents this in typed code, but the public API still needs a defensive runtime check for untyped call sites.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions