Skip to content

[BREAKING] update config parsing to propagate types errors#682

Merged
gbin merged 1 commit into
masterfrom
yang/fix/config_parsing_error_handling
Jan 20, 2026
Merged

[BREAKING] update config parsing to propagate types errors#682
gbin merged 1 commit into
masterfrom
yang/fix/config_parsing_error_handling

Conversation

@makeecat

@makeecat makeecat commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces a breaking change to config parsing throughout the Copper codebase. The core change is modifying ComponentConfig::get() to return Result<Option, ConfigError> instead of Option, enabling type errors to propagate rather than being silently
ignored.

Details

  • Core Changes (core/cu29_runtime/src/config.rs)

    1. New ConfigError type with proper error handling traits
    2. Changed ComponentConfig::get<T>() signature from Option<T> to Result<Option<T>, ConfigError>
    3. Added TryFrom<&Value> implementations for bool, integers, f64, and String with proper type-mismatch errors
    4. Updated serialize_ron() and deserialize_ron() to return CuResult instead of panicking
    5. Updated render() methods to propagate write errors instead of unwrapping
  • Additional Improvements

    1. Mutex poisoning recovery in cu29_log_runtime and cu29_unifiedlog
    2. CUDA error handling improvements in pool.rs
    3. Test updates to use the new error-returning APIs
    4. Removed panic-based tests in favor of proper error assertions

Migration Guide

  • ComponentConfig::get() Signature Change

    // Before:
    pub fn get<T: From<Value>>(&self, key: &str) -> Option<T>
    
    // After:
    pub fn get<T>(&self, key: &str) -> Result<Option<T>, ConfigError>
    where
        T: for<'a> TryFrom<&'a Value, Error = ConfigError>,
    
  • Migration Pattern

    // Before
    let value: u32 = config.get("key").unwrap_or(default);
    
    // After
    let value: u32 = config.get::<u32>("key")?.unwrap_or(default);
    
    // Before
    let value = config.and_then(|cfg| cfg.get::<String>("key"));
    
    // After
    let value = match config {
        Some(cfg) => cfg.get::<String>("key")?,
        None => None,
    };
    
  • Related Changes

    1. Node::get_param<T>() - same signature change
    2. CuConfig::serialize_ron() - now returns CuResult<String> instead of String
    3. CuConfig::deserialize_ron() - now returns CuResult<Self> instead of panicking

@makeecat

Copy link
Copy Markdown
Collaborator Author

@gbin should we treat it as a breaking change? If yes, I would mark a [BREAKING] in the title

@gbin

gbin commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator

Nice way more user friendly when you screw up ...

Please preemptively add the breaking change notice in the wiki in the release note for the unreleased 0.13 version so we don't forget thanks!

@makeecat makeecat changed the title update config parsing to propagate types errors [BREAKING] update config parsing to propagate types errors Jan 20, 2026
@makeecat

makeecat commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator Author

@gbin should we treat it as a breaking change? If yes, I would mark a [BREAKING] in the title

Wiki updated, migration guide included in the RP description.
If you feel confident with all changes on your side, you can merge.

@gbin gbin merged commit 3f39018 into master Jan 20, 2026
23 checks passed
@gbin gbin deleted the yang/fix/config_parsing_error_handling branch January 20, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants