Skip to content

Nightscout segment fails when API returns floating-point date value #7284

@shanselman

Description

@shanselman

What happened?

The Nightscout segment silently fails (returns disabled) when the Nightscout API returns a floating-point date field (e.g. 1770512410938.386) instead of an integer.

Some Nightscout providers (e.g. T1Pal) now return enriched entries where the date field includes fractional milliseconds. Go's json.Unmarshal cannot decode a float into the current int64 field, so the entire JSON parse fails and Enabled() returns false.

How to reproduce

Use a Nightscout URL that returns a response like:

[{"sgv":124,"date":1770512410938.386,"direction":"Flat",...}]

The segment will not render.

Expected behavior

The segment should handle both integer and floating-point date values.

Proposed fix

Change Date int64 to Date float64 in the NightscoutData struct. This is backward compatible - Go's JSON decoder can unmarshal integer JSON numbers into float64 without issues.

PR: #7285

Environment

  • Oh My Posh version: 28.8.1 (also confirmed in latest main)
  • OS: Windows
  • Shell: PowerShell 7.5.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions