Skip to content

Color(hex:) silently returns black on invalid input #25

Description

@nonatofabio

The Color(hex:) initializer in Theme.swift:69-77 uses Scanner.scanHexInt64 which returns 0 (black) on parse failure. No validation, no error. Not user-facing today (the color picker uses presets), but if anyone hand-edits a sidecar with "#XYZ" or "red" they get invisible marks.

Suggested fix. Make the initializer failable (init?(hex: String)) and handle nil at call sites with a fallback color, or assert in debug builds and fall back to accent in release.

References. Sources/mindle/Theme.swift:69-77.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions