Skip to content

[bug] forecast value 0.0 silently omitted from ConfigMap due to omitempty #71

Description

@amellier

Summary

EmissionsDataDto.Value is declared as float64 with json:"value,omitempty". In Go, omitempty on a numeric type omits the field when it equals the zero value (0.0). When a data provider returns 0.0 (e.g. during a WattTime outage), the field is silently dropped from the ConfigMap's binary data field.

Consumers reading the ConfigMap cannot distinguish "missing data" from a legitimate zero-intensity reading.

Steps to reproduce

  1. WattTime returns value: 0.0 from /v3/forecast
  2. Carbon Aware SDK passes it through unchanged
  3. The Go client decodes 0.0 into Value float64
  4. On re-encode with omitempty, the value key is absent from the ConfigMap binary data
{ "location": "CAISO_NORTH", "timestamp": "2026-04-23T16:25:00Z", "duration": 5 }

The value field is missing entirely rather than being 0 or null.

Suggested fix

Change Value float64 to Value *float64 in pkg/sdk/client/model_emissions_data_dto.go so that null (truly missing) is distinguishable from 0.0. Note: this file is swagger-generated — the same fix should be proposed upstream to the Carbon Aware SDK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions