# rclpy.exceptions.ParameterNotSetException: Parameter 'my_param' not set, but override was provided via --ros-args -p

- **ID:** `ros2/rclpy-parameter-override-not-applied`
- **Domain:** ros2
- **Category:** config_error
- **Error Code:** `RCLPY_PARAM_OVERRIDE_001`
- **Verification:** ai_generated
- **Fix Rate:** 87%

## Root Cause

The parameter override is provided before the node is declared, or the node declares the parameter with a different name/type, causing the override to be ignored.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Humble | active | — | — |
| Iron | active | — | — |
| Jazzy | active | — | — |

## Workarounds

1. **Declare the parameter with a default value before using it in the node: self.declare_parameter('my_param', 'default_value'). Then ensure the override is passed in the launch file after the node is started: <node pkg="my_pkg" exec="my_node" name="my_node"><param name="my_param" value="override_value"/></node>** (90% success)
   ```
   Declare the parameter with a default value before using it in the node: self.declare_parameter('my_param', 'default_value'). Then ensure the override is passed in the launch file after the node is started: <node pkg="my_pkg" exec="my_node" name="my_node"><param name="my_param" value="override_value"/></node>
   ```
2. **Use the 'allow_undeclared_parameters' option in the node's constructor: node = rclpy.create_node('my_node', allow_undeclared_parameters=True). Then overrides will be applied regardless of declaration order.** (85% success)
   ```
   Use the 'allow_undeclared_parameters' option in the node's constructor: node = rclpy.create_node('my_node', allow_undeclared_parameters=True). Then overrides will be applied regardless of declaration order.
   ```
3. **Move the parameter declaration to the beginning of the __init__ method, before any other node operations, and use the same name as in the override.** (80% success)
   ```
   Move the parameter declaration to the beginning of the __init__ method, before any other node operations, and use the same name as in the override.
   ```

## Dead Ends

- **Add more --ros-args -p arguments with different parameter names** — The issue is timing or naming, not the number of overrides; adding more won't fix the mismatch. (90% fail)
- **Use a YAML file instead of command-line -p arguments** — YAML files have the same timing and naming constraints; the root cause remains. (80% fail)
- **Set the parameter in the node's constructor before calling super().__init__()** — Parameters must be declared after the node is initialized; doing so before can cause undefined behavior. (85% fail)
