Skip to content

ENH: run the official RocketPy example designs unchanged - #77

Draft
aasitvora99 wants to merge 2 commits into
fix/generic-motor-guards-and-structured-errorsfrom
fix/rocketpy-example-fidelity
Draft

aasitvora99 wants to merge 2 commits into
fix/generic-motor-guards-and-structured-errorsfrom
fix/rocketpy-example-fidelity

Conversation

@aasitvora99

Copy link
Copy Markdown
Member

Stacked on #76 (base branch is fix/generic-motor-guards-and-structured-errors); retarget to master once #76 merges.

Why

Pushing the 17 official RocketPy example notebooks through the API as a regression corpus showed three API-boundary rejections that rocketpy itself does not make. None of these caused the October incidents; they matter because the examples are the natural regression suite for this API, and today 12 of 17 are refused at POST /motors/, /rockets/ and /flights/.

Changes

  • dry_inertia == (0, 0, 0) accepted for every motor kind. rocketpy's SolidMotor/LiquidMotor/HybridMotor take dry_inertia as a required argument but accept zeros; 12 of the 17 examples pass exactly (0, 0, 0), usually with dry_mass=0. The validate_dry_inertia_for_kind guard is removed.
  • FlightModel.max_time / min_time_step are floats. rocketpy takes floats; the lince example uses max_time=399.35159 and got "Input should be a valid integer".
  • Inline drag curves are built like the CSV loader. Notebooks hand rocketpy a CSV path, which goes through Rocket.__load_rocket_drag_csv (linear interpolation, constant extrapolation, duplicate Mach rows tolerated). The wire format forces an inline list, which rocketpy routes through Function(list) with the default spline interpolation; duplicate Mach rows (astra, cavour, erebus, hedy, SEB) make the spline solve NaN and the rocket is rejected with "Invalid list/tuple format". RocketService._drag_curve_function now sorts by Mach, keeps the first of any duplicate, and builds the Function with the CSV loader's settings.

Verification

  • pytest tests/unit: all passing (7 new tests: zero inertia builds a SolidMotor; float flight fields; drag dedup/sort/interpolation; a rocket with duplicate Mach rows constructs and evaluates).
  • Regression corpus (17 example designs) on this branch: 14 of 17 run end to end through motors, rockets, environments and flights; the remaining three are documented upstream rocketpy 1.12.1 issues (Defiance/Halcyon hybrid tanks drain to exactly 0 kg and tank.py has no tolerance; Astra max_rail_button1_normal_force spline NaN), all reproducible with plain rocketpy and the notebook's own numbers.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d062d50c-a286-4dee-92e7-6c62a3e6440e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

… ValueErrors, malformed ids; accept motorless rockets

Replaying the Oct 2026 production P0s against a local instance showed four
opaque 500s and a non-standard 422 body:

- GENERIC motors with chamber_radius/height/position or
  propellant_initial_mass = None constructed fine and crashed on first use
  (Function(None) in center_of_propellant_mass). MotorService now raises
  422 "Generic motor requires: a, b" naming every missing field.
- RocketPy ValueErrors (overfilled tank, etc.) were wrapped as 500; the
  controller handler now maps them to 422 with the message.
- ObjectId("undefined") raised InvalidId -> 500; find_by_id returns None
  (404 upstream), update/delete raise 404.
- The RequestValidationError handler returned a bare string; it now returns
  FastAPI's standard {"detail": [{loc, msg, type}]}.

RocketModel.motor is now Optional: a rocket saved before its motor exists
keeps rocketpy's EmptyMotor (draws fine); rocket/flight simulate answer 422
"Rocket has no motor yet" via RocketService.require_motor().

Tests: 199 passing (18 new).
@aasitvora99
aasitvora99 force-pushed the fix/generic-motor-guards-and-structured-errors branch from 87dd5b3 to 1ea89c6 Compare October 18, 2026 15:45
@aasitvora99
aasitvora99 force-pushed the fix/rocketpy-example-fidelity branch from 1b7ede7 to 5a37cf6 Compare October 18, 2026 15:46
@aasitvora99
aasitvora99 force-pushed the fix/generic-motor-guards-and-structured-errors branch from 1ea89c6 to fce4a21 Compare October 18, 2026 15:51
…ertia, float flight times, list drag curves)

Pushing the 17 RocketPy example notebooks through the API as a regression
corpus showed three API-boundary blockers that rocketpy itself does not have:

- dry_inertia == (0, 0, 0) was rejected for SOLID/LIQUID/HYBRID. rocketpy
  accepts zeros (12 of the 17 official examples pass exactly (0, 0, 0),
  usually with dry_mass=0). Validator removed.
- FlightModel.max_time / min_time_step were typed int; rocketpy.Flight
  takes floats (lince uses max_time=399.35159).
- Inline drag lists went through Function(list) with the default spline
  interpolation; duplicate Mach rows (five of the example drag CSVs) made
  the spline solve NaN and the rocket was rejected with "Invalid list/tuple
  format". The rocket service now builds drag curves the way rocketpy's
  CSV loader does: linear interpolation, constant extrapolation, duplicate
  Mach rows collapsed (first kept).

With these, 14 of 17 example designs run end to end through
/motors, /rockets and /flights; the remaining three are upstream rocketpy
1.12.1 issues (hybrid tanks draining to exactly 0 kg; astra rail-button NaN).

Tests: 7 new.
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