Skip to content

fix(environment): default missing wind to 0 for custom_atmosphere#74

Open
Gui-FernandesBR wants to merge 1 commit into
masterfrom
fix/env-wind-none-guard
Open

fix(environment): default missing wind to 0 for custom_atmosphere#74
Gui-FernandesBR wants to merge 1 commit into
masterfrom
fix/env-wind-none-guard

Conversation

@Gui-FernandesBR

@Gui-FernandesBR Gui-FernandesBR commented Jul 23, 2026

Copy link
Copy Markdown
Member

Default missing wind to 0 for custom_atmosphere

RocketPy's set_atmospheric_model guards pressure/temperature against None but not wind. A custom_atmosphere environment with wind_u/wind_v left unset therefore raised AttributeError: 'NoneType' object has no attribute 'shape' and hard-failed the simulation.

EnvironmentService.from_env_model now defaults a None wind component to 0.0. Only None is replaced — a real 0.0 and wind-profile lists pass through untouched.

Why

Surfaced from the Jarvis beta-prep audit: the web client seeds wind as null and only writes on user edit, so the default Custom-atmosphere path crashed the sim (UI showed 0 while sending null). Jarvis has been fixed to coerce null → 0 on egress; this is the belt-and-suspenders guard on the backend so any client (or a direct API call) is safe.

Test

set_atmospheric_model(type='custom_atmosphere', wind_u=None) reproduced the crash; with wind_u=0.0 it succeeds.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where custom atmospheric models could fail when wind values were left unspecified.
    • Unspecified wind components are now safely treated as calm conditions.

RocketPy's set_atmospheric_model guards pressure/temperature against None but
not wind, so a custom_atmosphere environment with wind_u/wind_v left unset
raised "'NoneType' object has no attribute 'shape'" and hard-failed the
simulation. Default a None wind component to 0.0 (only None is replaced — real
0.0 values and wind-profile lists pass through untouched).

Surfaced from the Jarvis beta audit: the web client seeds wind as null and only
writes on user edit, so the default Custom-atmosphere path crashed. Jarvis now
coerces null->0 on egress too; this is the belt-and-suspenders backend guard.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

EnvironmentService.from_env_model now replaces None wind components with 0.0 before configuring the RocketPy atmospheric model.

Changes

Environment wind defaults

Layer / File(s) Summary
Normalize missing wind inputs
src/services/environment.py
from_env_model defaults unset wind_u and wind_v values to 0.0 when calling set_atmospheric_model.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: aasitvora99

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: defaulting missing wind values to 0 for custom_atmosphere environments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/env-wind-none-guard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/services/environment.py (2)

34-34: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Wrap the comment to stay within 79 characters.

Line 34 exceeds the repository’s configured line-length limit. As per coding guidelines: **/*.py: Target Python 3.12 and enforce 79-character line length using Black, Ruff, and Pylint.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/services/environment.py` at line 34, Wrap the comment near the
environment value handling so every line is no longer than 79 characters,
preserving its meaning that only None is replaced while real 0.0 values and wind
profiles pass through.

Source: Coding guidelines


35-41: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for the normalization contract.

Cover both components being unset, only one component being unset, explicit 0.0, and profile lists. This verifies that only None is replaced and that existing wind inputs remain unchanged.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/services/environment.py` around lines 35 - 41, Add regression tests for
the atmospheric model setup in the environment service, covering both wind
components unset, either component unset individually, explicit 0.0 values, and
profile-list inputs. Assert that only None values normalize to 0.0 and all
existing wind inputs remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/services/environment.py`:
- Line 34: Wrap the comment near the environment value handling so every line is
no longer than 79 characters, preserving its meaning that only None is replaced
while real 0.0 values and wind profiles pass through.
- Around line 35-41: Add regression tests for the atmospheric model setup in the
environment service, covering both wind components unset, either component unset
individually, explicit 0.0 values, and profile-list inputs. Assert that only
None values normalize to 0.0 and all existing wind inputs remain unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 08c092ef-94bd-48ce-8458-ecc8942284b4

📥 Commits

Reviewing files that changed from the base of the PR and between cf325e4 and 973fd8b.

📒 Files selected for processing (1)
  • src/services/environment.py

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant