Skip to content

fix(s3): use ConfigProvider for FLOCI_HOSTNAME to fix native image crash#3

Open
Meemaw wants to merge 3 commits intomainfrom
devin/1775649968-fix-floci-hostname-native
Open

fix(s3): use ConfigProvider for FLOCI_HOSTNAME to fix native image crash#3
Meemaw wants to merge 3 commits intomainfrom
devin/1775649968-fix-floci-hostname-native

Conversation

@Meemaw
Copy link
Copy Markdown
Member

@Meemaw Meemaw commented Apr 8, 2026

Summary

S3VirtualHostFilter used @ConfigProperty constructor injection for floci.hostname, which gets baked into the GraalVM native binary at build time. Setting FLOCI_HOSTNAME at runtime via Docker env var caused:

IllegalStateException: the runtime value of 'floci.hostname' is [localhost]
but the value [null] was injected into S3VirtualHostFilter()

This PR replaces the @Inject/@ConfigProperty constructor with a no-arg constructor that reads config via ConfigProvider.getConfig() at runtime. @PreMatching JAX-RS filters are instantiated before CDI beans are fully initialized, so neither @ConfigProperty nor @ConfigMapping (EmulatorConfig) injection works — both cause SRCFG00027 at startup.

Additionally, bucket extraction is now hostname-aware: the first label is only treated as a bucket name when the remainder matches the configured base hostname (or a well-known AWS S3 domain like *.s3.amazonaws.com). Previously, any subdomain was treated as a bucket, which caused false positives in multi-label hostname environments (e.g. floci.svc.cluster.local would incorrectly extract floci as a bucket name).

Updates since last revision

  • Replaced @Inject EmulatorConfig approach with programmatic ConfigProvider.getConfig().getOptionalValue() — the EmulatorConfig @ConfigMapping bean also fails to inject in @PreMatching filters
  • Added inline comment explaining the CDI timing constraint

Type of change

  • Bug fix (fix:)

AWS Compatibility

Incorrect behavior: FLOCI_HOSTNAME env var crashes the native image on startup. Without it, virtual-host bucket extraction has no hostname awareness, causing false positives in Docker Compose / Kubernetes setups.

Important for review

  • effectiveBaseUrl() logic duplication: The hostname-into-URL replacement regex from EmulatorConfig.effectiveBaseUrl() is duplicated in the constructor (~3 lines). This is unavoidable since CDI injection is not available in @PreMatching filters; worth verifying the regex stays in sync.
  • Breaking behavioral change in extractBucket: The old heuristic (first-label-is-always-a-bucket) is replaced with hostname-matching. Users with arbitrary custom hostnames (e.g. my-bucket.myhost:4566) must now set FLOCI_HOSTNAME=myhost for virtual-hosted-style to work. Path-style requests are unaffected.
  • isAwsS3Domain fallback: Only covers s3.amazonaws.com and s3.<region>.amazonaws.com. Other S3 endpoint patterns (e.g. s3-external-1.amazonaws.com) are not matched.
  • No integration test for FLOCI_HOSTNAME: The unit tests cover extractBucket with various baseHostname values, but there's no Quarkus integration test that sets FLOCI_HOSTNAME as a config override and verifies end-to-end virtual-host routing.

Checklist

  • ./mvnw test passes locally
  • New or updated integration test added
  • Commit messages follow Conventional Commits

Link to Devin session: https://app.devin.ai/sessions/06b7e28f3e664783b17ed18060e5c267
Requested by: @Meemaw


Open with Devin

@devin-ai-integration
Copy link
Copy Markdown

Original prompt from Matej

switch from localstsvk to floci. Minimal vode changes, just change the container image

@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

S3VirtualHostFilter used @ConfigProperty injection in its constructor,
which gets baked into the GraalVM native binary at build time. Setting
FLOCI_HOSTNAME at runtime via Docker env var caused an
IllegalStateException because the runtime value differed from the
build-time value (null).

Refactor to inject EmulatorConfig (which uses @ConfigMapping and is
runtime-safe) instead of raw @ConfigProperty, following the established
pattern used by StorageFactory, ServiceRegistry, RegionResolver, etc.

Also make bucket extraction hostname-aware: only treat the first label
as a bucket name when the remainder matches the configured base
hostname (or a well-known AWS S3 domain). This prevents false positives
when Floci sits behind a multi-label hostname like
floci.svc.cluster.local.

Co-Authored-By: Matej Snuderl <ematej.snuderl@gmail.com>
…tFilter

Replace @Inject EmulatorConfig with programmatic ConfigProvider.getConfig()
to fix SRCFG00027 error. @PreMatching JAX-RS filters run before CDI beans
are fully initialized, so @ConfigMapping beans like EmulatorConfig are not
available during filter construction.

Co-Authored-By: Matej Snuderl <ematej.snuderl@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

…nject

Co-Authored-By: Matej Snuderl <ematej.snuderl@gmail.com>
@devin-ai-integration devin-ai-integration bot changed the title fix(s3): use EmulatorConfig for FLOCI_HOSTNAME to fix native image crash fix(s3): use ConfigProvider for FLOCI_HOSTNAME to fix native image crash Apr 8, 2026
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.

1 participant