Describe the bug
If you write a module, which implements the impl Merge for ModuleConfig and returns return Err(MergeConfigError::NoValue);, nginx startup fails without any error message.
To Reproduce
Steps to reproduce the behavior:
- Build the project.
- Load awssig module into project
- Activate AWS signature mode in a location with
awssigv4 on; only (no other locations)
- nginx fails to startup without any error message
Expected behavior
I expect to see at least an error message that the config merge failed.
I would suggest to enhance the interface so that self written modules, implementing the trait, are able to pass a string in the error to be able to describe the message actually.
Your environment
- Version of fb86580
- Version of Rust:
cargo 1.96.0 (30a34c682 2026-05-25)
Additional context
A possible fix. This introduced warnings in the build, but I guess you understand my wish much better:
Details
diff --git a/src/http/module.rs b/src/http/module.rs
index c19c61c..27fd8dd 100644
--- a/src/http/module.rs
+++ b/src/http/module.rs
@@ -6,6 +6,7 @@ use core::ptr;
use crate::core::NGX_CONF_ERROR;
use crate::core::*;
use crate::ffi::*;
+use crate::ngx_conf_log_error;
/// MergeConfigError - configuration cannot be merged with levels above.
#[derive(Debug)]
@@ -118,7 +119,7 @@ pub trait HttpModule {
/// Callers should provide valid non-null `ngx_conf_t` arguments. Implementers must
/// guard against null inputs or risk runtime errors.
unsafe extern "C" fn merge_srv_conf(
- _cf: *mut ngx_conf_t,
+ cf: *mut ngx_conf_t,
prev: *mut c_void,
conf: *mut c_void,
) -> *mut c_char
@@ -131,7 +132,10 @@ pub trait HttpModule {
let conf = &mut *(conf as *mut Self::ServerConf);
match conf.merge(prev) {
Ok(_) => ptr::null_mut(),
- Err(_) => NGX_CONF_ERROR as _,
+ Err(e) => {
+ ngx_conf_log_error!(NGX_LOG_EMERG, cf, "failed to merge server configuration: {}", e);
+ NGX_CONF_ERROR as _
+ }
}
}
}
@@ -156,7 +160,7 @@ pub trait HttpModule {
/// Callers should provide valid non-null `ngx_conf_t` arguments. Implementers must
/// guard against null inputs or risk runtime errors.
unsafe extern "C" fn merge_loc_conf(
- _cf: *mut ngx_conf_t,
+ cf: *mut ngx_conf_t,
prev: *mut c_void,
conf: *mut c_void,
) -> *mut c_char
@@ -169,7 +173,10 @@ pub trait HttpModule {
let conf = &mut *(conf as *mut Self::LocationConf);
match conf.merge(prev) {
Ok(_) => ptr::null_mut(),
- Err(_) => NGX_CONF_ERROR as _,
+ Err(e) => {
+ ngx_conf_log_error!(NGX_LOG_EMERG, cf, "failed to merge location configuration: {}", e);
+ NGX_CONF_ERROR as _
+ }
}
}
}
There is still no error message passable via this interface, but this is my 2nd day really programming rust. I'm not yet aware what's the best solution to do the inheritance for this wish.
Describe the bug
If you write a module, which implements the
impl Merge for ModuleConfigand returnsreturn Err(MergeConfigError::NoValue);, nginx startup fails without any error message.To Reproduce
Steps to reproduce the behavior:
awssigv4 on;only (no other locations)Expected behavior
I expect to see at least an error message that the config merge failed.
I would suggest to enhance the interface so that self written modules, implementing the trait, are able to pass a string in the error to be able to describe the message actually.
Your environment
cargo 1.96.0 (30a34c682 2026-05-25)Additional context
A possible fix. This introduced warnings in the build, but I guess you understand my wish much better:
Details
There is still no error message passable via this interface, but this is my 2nd day really programming rust. I'm not yet aware what's the best solution to do the inheritance for this wish.