EarthMind rejects valid readings whose value is 0

Open Beginner friendly
#1,136 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@snehaapratap is already working on this.

Since Nov 2, 2026.

  • #1164 by @snehaapratap — open

Assessment

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

Research direction

Start in _ingest_reading in earthmind/src/index.py (around line 127), where the required-field check uses a truthiness test that rejects 0. Read the README's API Reference and Running Tests sections, then check how env.DB is used so you can build a small fake for the new earthmind/tests/test_ingest.py. Done when POST /api/data accepts value: 0, rejects NaN, Infinity and out-of-range coordinates with 400, and python -m pytest tests/ passes.

Written by the indexing model from the issue text.

Description

2026-11 bug good first issue gsoc-2027 project: earthmind
Context

_ingest_reading in earthmind/src/index.py (~line 127) checks required fields with:

missing = [f for f in required if not body.get(f)]

Because 0 is falsy, a perfectly valid reading such as {"parameter": "rainfall", "value": 0, ...} is rejected with 400 Missing required fields: value. Zero is a common real value (rainfall, wind speed, many pollutant readings at night). The same check also accepts "nan" / "inf" strings, because float("nan") succeeds.

What to do
  • Treat a field as missing only when it is absent, None, or an empty string.
  • Reject non-finite values (math.isfinite) with a 400.
  • Validate latitude in [-90, 90] and longitude in [-180, 180] when provided.
  • Add tests (new earthmind/tests/test_ingest.py with a tiny fake env.DB) for value 0, missing value, NaN, and out-of-range coordinates.
Acceptance criteria
  • POST /api/data with value: 0 returns 201.
  • NaN/Infinity and invalid coordinates return 400.
  • New tests pass with python -m pytest tests/.
Files
  • earthmind/src/index.py (_ingest_reading)
  • earthmind/tests/ (new test file)
Helpful links
  • earthmind/README.md (API Reference, Running Tests)

Part of GSoC 2027 onboarding — see https://gsoc.alphaonelabs.com

Dominant language
HTML
Stars
66
Forks
181
Avg merge
2h 21m
Merged PRs (30d)
13

Getting set up

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.

More from alphaonelabs/website

All issues in alphaonelabs/website

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.