louis-e/arnis · error
Elevation data not available
Error message
Elevation data not available
What it means
save_debug_image unconditionally expects self.elevation_data to be Some, unwrapping it with .expect. If the ground generator ran without elevation data (provider failed, disabled, or not yet loaded), the Option is None and this panic fires. Notably it is raised in a debug-image helper invoked from generate_ground_data, so a missing-elevation condition surfaces as an unrelated-looking panic during generation.
Source
Thrown at src/ground.rs:914
};
img.put_pixel(x as u32, z as u32, color);
}
}
let filename: String = if !filename.ends_with(".png") {
format!("{filename}.png")
} else {
filename.to_string()
};
if let Err(e) = img.save(&filename) {
eprintln!("Failed to save canopy debug image: {e}");
}
}
fn save_debug_image(&self, filename: &str) {
let heights = &self
.elevation_data
.as_ref()
.expect("Elevation data not available")
.heights;
if heights.is_empty() || heights[0].is_empty() {
return;
}
let height: usize = heights.len();
let width: usize = heights[0].len();
let mut img: image::ImageBuffer<Rgb<u8>, Vec<u8>> =
RgbImage::new(width as u32, height as u32);
let mut min_height: f32 = f32::MAX;
let mut max_height: f32 = f32::MIN;
for row in heights {
for &h in row {
if h.is_finite() {
min_height = min_height.min(h);
max_height = max_height.max(h);View on GitHub (pinned to 34048924d9)
Solutions
- Make save_debug_image take the elevation data as a parameter or return early (log a warning) when elevation_data is None, instead of expect-ing.
- Fix the root cause: ensure generate_ground_data either has elevation data or skips elevation-dependent debug output when it is absent.
- If elevation data is required, fail generate_ground_data with a clear 'elevation data unavailable' error before doing any work.
Example fix
// before
let heights = &self.elevation_data.as_ref().expect("Elevation data not available").heights;
// after
let Some(elevation) = self.elevation_data.as_ref() else {
eprintln!("save_debug_image: skipped, no elevation data");
return;
};
let heights = &elevation.heights; Defensive patterns
Strategy: type-guard
Type guard
fn has_elevation(g: &GroundData) -> bool { g.elevation_data.is_some() } Try / catch
// Rust panic; avoid by narrowing first
if let Some(elevation) = &self.elevation_data {
self.write_debug_image(filename, &elevation.heights);
} else {
log::warn!("save_debug_image skipped: no elevation data");
} Prevention
- Skip elevation-dependent debug output when elevation_data is None
- Surface elevation provider failures explicitly instead of leaving the field None
- Test generate_ground_data with elevation disabled to ensure no hidden panics
When it happens
Trigger: generate_ground_data calls save_debug_image while self.elevation_data is None — i.e. elevation data was never assigned because the elevation provider failed or was skipped, and the debug-image path was enabled.
Common situations: Debug image output enabled in config while elevation fetching failed silently or was disabled; calling generate_ground_data before elevation data finished loading; a refactor that made elevation_data optional without updating the debug-image path.
Related errors
- provider chain is never empty
- select_level_for_cell_size called with empty levels
- Earth has no PDS raster
- Invalid id
- Failed to create tile XZBBox
AI-assisted analysis of louis-e/arnis@34048924d9 (2026-09-03).
Data as JSON: /api/errors/42ddf1613d8d632e.
Report an issue: GitHub.