Skip to content

fix: un-orphan build()'s #[cfg(native)] from with_secret_resolver - #1566

Merged
bplatz merged 1 commit into
mainfrom
fix/api-orphaned-native-cfg
Jul 31, 2026
Merged

bplatz merged 1 commit into
mainfrom
fix/api-orphaned-native-cfg

Conversation

@bplatz

@bplatz bplatz commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

fluree-db-api does not compile for any consumer using default-features = false. On current main:

$ cargo check -p fluree-db-api --no-default-features --features aws,iceberg,shacl
error[E0609]: no field `storage_path` on type `FlureeBuilder`   lib.rs:1991
error[E0433]: cannot find type `FileStorage`                    lib.rs:1995
error[E0433]: cannot find type `FileNameService`                lib.rs:1996

f305df480 (#1500 §3, ConfigValue::SecretRef) inserted FlureeBuilder::with_secret_resolver between build()'s doc comment and its #[cfg(feature = "native")] attribute, so the gate attached to the wrong function:

    /// Build a file-backed Fluree instance
    /// ...
    #[cfg(feature = "native")]        // <-- was build()'s gate
    /// Inject a secret resolver ...
    #[cfg(feature = "iceberg")]
    pub fn with_secret_resolver(...) -> Self { ... }

    pub fn build(mut self) -> Result<Fluree> {   // <-- ungated, native-only body

Two consequences:

  • build() was left cfg-less, so a no-native compile pulls in its native-only body (storage_path / FileStorage / FileNameService) and fails.
  • with_secret_resolver became native + iceberg, over-gating the no-native BYO-IAM SecretRef surface it was added for behind native.

Fix

Move with_secret_resolver (with its own doc comment and #[cfg(iceberg)]) after build(), rejoining build()'s doc comment with its #[cfg(native)]. with_secret_resolver is now gated on iceberg only.

Two follow-ons so the no-native featureset is genuinely clean rather than merely compiling — both pre-existing, both invisible until the crate could compile at all on this featureset:

  • WARM_BUDGET_{NUMERATOR,DENOMINATOR} gated on native (their only consumer, warm_budget_bytes(), already is) — otherwise two dead_code warnings.
  • One inlined format arg in the #[cfg(not(feature = "native"))] build_local_storage_from_config — otherwise a clippy::uninlined_format_args denial.

Why CI never caught this

--all-features and workspace builds structurally mask this class of bug through feature unification: native is always on, so no existing job ever compiles the no-native combination downstream lambda consumers actually use. Worth adding that exact featureset as a CI job; not done here to keep this reviewable.

Verification

Gate Before After
check -p fluree-db-api --no-default-features --features aws,iceberg,shacl FAIL (3 errors) pass
clippy same featureset, -D warnings FAIL pass
check -p fluree-db-api --features iceberg (native default) pass pass
clippy -p fluree-db-api --all-features --all-targets -D warnings pass pass
cargo fmt --all -- --check clean clean

Behavior under --all-features is unchanged — the cfg expansion is identical to before, so the workspace test suite is unaffected by construction.

Note on history

988b1affb (Andrew Johnson, Jul 20) fixed this same gate and is on audit-program/land-on-main, feat/materialize-builder, perf/browse-parity, perf/family-c-filter-join and perf/audit-mainmerge-base — but it never reached main. This commit supersedes it; those branches will resolve on their next merge from main.

The bug was reported against 3a87233d on fix/upsert-staging-new-subject-scan, with a request to cherry-pick there. That branch is already merged into main, so fixing it on main instead covers it and the 15 other live refs descending from f305df480 that still carry the orphaned gate.

f305df4 (#1500 §3 SecretRef) inserted FlureeBuilder::with_secret_resolver
BETWEEN build()'s doc comment and its #[cfg(feature = "native")] attribute,
so the gate landed on with_secret_resolver instead:

- build() was left cfg-less, so any no-native compile pulled in its
  native-only body (storage_path / FileStorage / FileNameService) and failed;
- with_secret_resolver became native + iceberg, over-gating the no-native
  BYO-IAM SecretRef surface it exists for behind native.

Move with_secret_resolver (its own doc + #[cfg(iceberg)]) after build(),
rejoining build()'s doc with its #[cfg(native)]. with_secret_resolver is now
gated on iceberg ONLY.

Two follow-ons so the no-native featureset is actually clean, not merely
compiling: gate WARM_BUDGET_{NUMERATOR,DENOMINATOR} on native (their only
consumer, warm_budget_bytes(), already is) and inline a format arg in the
not(native) build_local_storage_from_config.

Verified: cargo check + clippy -D warnings for
  -p fluree-db-api --no-default-features --features aws,iceberg,shacl
FAILED before and are clean after; native default + iceberg and the
--all-features --all-targets clippy CI gate still pass.

--all-features and workspace builds structurally mask this class of bug via
feature unification -- native is always on there, so no existing CI job ever
compiles the no-native combination downstream lambda consumers use.

Supersedes the never-landed 988b1af, which fixed the same gate on the
browse-parity lineage but never reached main.
@bplatz
bplatz requested review from aaj3f and zonotope July 30, 2026 10:49

@aaj3f aaj3f left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surgical and verified: the orphaned #[cfg(native)] is reattached to build(), with_secret_resolver is re-gated on iceberg only (un-hiding the no-native SecretRef surface it exists for), and the two follow-ons make the no-native featureset clippy-clean rather than merely compiling. I reproduced both directions in an isolated worktree — parent commit fails cargo check -p fluree-db-api --no-default-features --features aws,iceberg,shacl with exactly the claimed E0609 storage_path / E0433 FileStorage / E0433 FileNameService, and HEAD passes both check and clippy -D warnings on that combination — and solo's green rust-lambdas CI at the f8d3267 pin (fluree/solo#888) independently confirms the downstream consumers compile again.

The one thing I'd suggest (if not now than as a follow-up): a CI gate that compiles the no-native combination, because feature unification guarantees the current matrix can never catch this class and this is its second occurrence.

Adherence to repo commitments:

  • Testing: ⚠️ No automated guard added — inherent to the class (it needs a feature-combination compile gate, not a unit test); verified manually in both directions here, and the recommended CI check is the durable fix.

Recommend merge — and merge this before fluree/solo#888, which pins this exact head; once merged (fluree/db uses merge commits, so f8d3267 stays reachable from main), the solo pin is durable.


Notes without a diff anchor:

.github/workflows/ci.yml (not in this diff — no honest anchor, so this belongs in the review body) — optional but strongly recommended. The commit body itself names the structural gap: feature unification means --all-features and workspace builds are always-native, so no CI job ever compiles the no-native combination downstream lambda consumers use — which is exactly why f305df480 shipped broken and every solo Lambda build died at the 3a87233 pin. This is now the second incarnation of the class (over-gating/under-gating that only no-native surfaces). A single cheap gate closes it permanently: cargo check -p fluree-db-api --no-default-features --features aws,iceberg,shacl (34 s incremental in my run; a few minutes cold) — or cargo clippy … -- -D warnings for the stricter version that also catches the dead-const hygiene this PR had to patch. Without it, the next attribute drift ships the same way and is again discovered by solo's build breaking.

@bplatz
bplatz merged commit d894ebb into main Jul 31, 2026
20 of 21 checks passed
@bplatz
bplatz deleted the fix/api-orphaned-native-cfg branch July 31, 2026 02:49
aaj3f added a commit that referenced this pull request Jul 31, 2026
…conflict-free review

Single conflict: fluree-db-api/src/lib.rs — convergent cfg-orphan fix.
Both #1566 and the audit side moved build()'s #[cfg(native)] doc block
below with_secret_resolver (kept iceberg-gated). The cfg fix is
byte-identical on both sides; resolved the lone doc-wording hunk to
main's #1566 text, so the merged file equals origin/main's api/lib.rs
(zero diff, no audit feature lost). hash_join.rs, optional.rs, planner.rs
auto-merged (disjoint hunks: audit #1477 fast-path vs main cypher #1553).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants