neon-bindings/neon · error

Unknown attribute

Error message

Unknown attribute '{}'

What it means

Compile-time error raised while parsing the top-level attributes after `export(class ...)` (not inside the parentheses). Only `name` is accepted as an additional attribute; any other key triggers this error. It protects the `class` export's metadata parsing from unsupported options.

Solutions

  1. Use `name` as the attribute key: `export(class, name = "bindingName")`.
  2. Remove the unsupported attribute entirely if the default export name is fine.
  3. Verify against the current Neon documentation that the attribute you want exists for class exports.

Example fix

// before
#[neon]
export(class, export_name = "MyClass")
// after
#[neon]
export(class, name = "MyClass")
Defensive patterns

Strategy: validation

Validate before calling

// Only `name` is valid as a top-level attribute after export(class ...):
// verify every top-level key is exactly `name`:
// #[neon] export(class, name = "...")
const VALID_TOP_LEVEL_ATTRS: [&str; 1] = ["name"];
fn check_top_level_attr(attr: &str) -> Result<(), String> {
    if VALID_TOP_LEVEL_ATTRS.contains(&attr) { Ok(()) } else { Err(format!("Unknown attribute '{}'", attr)) }
}

Prevention

When it happens

Trigger: Writing `#[neon] export(class, rename = "binding")` or any identifier other than `name` following `class` at the top level of the export attribute (e.g. `export(class, export = "x")`).

Common situations: Confusing the function-export attribute surface with the class one, attempting to set a JS export name with a made-up key, or following outdated documentation/examples from older Neon versions.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of neon-bindings/neon@38960e4381 (2026-09-13). Data as JSON: /api/errors/857ae7455390fdea. Report an issue: GitHub.

Appendix: source

Thrown at crates/neon-macros/src/export/class/meta.rs:68

                    break;
                }
            }
        }

        // Check if there are additional attributes after "class" or "class(...)"
        if input.parse::<syn::Token![,]>().is_ok() {
            // Parse additional attributes like name = "..."
            while !input.is_empty() {
                let name_token: syn::Ident = input.parse()?;

                match name_token.to_string().as_str() {
                    "name" => {
                        input.parse::<syn::Token![=]>()?;
                        let name_value: syn::LitStr = input.parse()?;
                        meta.export_name = Some(name_value.value());
                    }
                    _ => {
                        return Err(syn::Error::new(
                            name_token.span(),
                            format!("Unknown attribute '{}'", name_token),
                        ));
                    }
                }

                // Parse optional comma
                if input.parse::<syn::Token![,]>().is_err() {
                    break;
                }
            }
        }

        Ok(meta)
    }
}

/// Parser for class export metadata

View on GitHub (pinned to 38960e4381)