openclimatefix / openclimatefix/nwp-consumer

Zero division error in _fold_dataarrays_generator

Open Beginner friendly
#306 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
17
Forks
10
Avg merge
1h 46m
Merged PRs (30d)
1

Description

Describe the bug

Division by zero error if no results yielded by generator (error potential on last line of snippet):

https://github.com/openclimatefix/nwp-consumer/blob/3272c0a68aa000361506e479deb932d335d3004a/src/nwp_consumer/internal/services/consumer_service.py#L59-L86

To Reproduce

Provide a generator with no results to yield.

Expected behavior

An explicit exception thrown by an extra check added, before trying to divide by the results length.

Additional context

This division by zero error occurred in Airflow when downloading Met Office data at 2026-04-24 05:12:45

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/nwp_consumer/internal/services/consumer_service.py at the linked lines 59-86 and trace how the generator results are collected and divided. Reproduce the case with a generator that yields nothing. Done means the empty-result case raises an explicit exception before division, rather than producing a zero-division error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.