cube-js/cube · error · syn::Error

unknown native_bridge flag (expected `without_imports` or…

Error message

unknown native_bridge flag (expected `without_imports` or `with_static_meta`)

What it means

The #[native_bridge] attribute macro only accepts two helper flags: `without_imports` and `with_static_meta`. When a flag-like attribute argument (looks_like_flag) is present but matches neither known name, the macro bails out and emits this compile error so the developer knows the attribute is misspelled or unsupported.

Solutions

  1. Replace the unknown flag with `without_imports` or `with_static_meta` exactly as spelled (lowercase snake_case).
  2. If the intent was to skip generated imports, use `#[native_bridge(without_imports)]`.
  3. If the intent was to embed static metadata, use `#[native_bridge(with_static_meta)]`.
  4. Check the nativebridge crate version in Cargo.toml and its docs — the set of supported flags may differ between versions.

Example fix

// before
#[native_bridge(without_import)]
trait MyService { }

// after
#[native_bridge(without_imports)]
trait MyService { }
Defensive patterns

Strategy: validation

Validate before calling

// Check attribute flags before compiling
const ALLOWED: [&str; 2] = ["without_imports", "with_static_meta"];
fn valid_flags(attrs: &[&str]) -> bool {
    attrs.iter().all(|a| ALLOWED.contains(a))
}
// usage: assert!(valid_flags(&["without_imports"]));

Prevention

When it happens

Trigger: Annotating a trait with #[native_bridge(...)] and passing an unrecognized flag such as #[native_bridge(without_import)], #[native_bridge(With_Static_Meta)], #[native_bridge(no_imports)], or any typo/renamed flag inside the parentheses.

Common situations: Typos or singular/plural mistakes when copying examples, renaming of flags across crate versions, or inventing a flag assuming the macro supports it (e.g. trying to disable imports with a different name).

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/b7c64ee1272bb58e. Report an issue: GitHub.

Appendix: source

Thrown at rust/cube/cubesqlplanner/nativebridge/src/lib.rs:25

use syn::token::PathSep;
use syn::LitStr;
use syn::{
    parse_macro_input, punctuated::Punctuated, Data, DeriveInput, Fields, FnArg, Item, Meta, Pat,
    Path, PathArguments, PathSegment, ReturnType, TraitItem, TraitItemFn, Type,
};
#[proc_macro_attribute]
pub fn native_bridge(args: TokenStream, input: TokenStream) -> proc_macro::TokenStream {
    let mut svc = parse_macro_input!(input as NativeService);
    let args = parse_macro_input!(args with Punctuated::<Meta, syn::Token![,]>::parse_terminated);
    for arg in args.iter() {
        match arg {
            Meta::Path(p) => {
                if p.is_ident("without_imports") {
                    svc.without_imports = true;
                } else if p.is_ident("with_static_meta") {
                    svc.with_static_meta = true;
                } else if looks_like_flag(p) {
                    return syn::Error::new(
                        p.span(),
                        "unknown native_bridge flag (expected `without_imports` or `with_static_meta`)",
                    )
                    .to_compile_error()
                    .into();
                } else {
                    svc.static_data_type = Some(p.clone())
                }
            }
            _ => {}
        }
    }

    proc_macro::TokenStream::from(svc.into_token_stream())
}

fn looks_like_flag(path: &Path) -> bool {
    if path.segments.len() != 1 {

View on GitHub (pinned to 7d981676b3)