fix(s3): use ConfigProvider for FLOCI_HOSTNAME to fix native image crash#3
Open
fix(s3): use ConfigProvider for FLOCI_HOSTNAME to fix native image crash#3
Conversation
Original prompt from Matej
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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>
550640c to
6364abe
Compare
7 tasks
…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>
…nject Co-Authored-By: Matej Snuderl <ematej.snuderl@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
S3VirtualHostFilterused@ConfigPropertyconstructor injection forfloci.hostname, which gets baked into the GraalVM native binary at build time. SettingFLOCI_HOSTNAMEat runtime via Docker env var caused:This PR replaces the
@Inject/@ConfigPropertyconstructor with a no-arg constructor that reads config viaConfigProvider.getConfig()at runtime.@PreMatchingJAX-RS filters are instantiated before CDI beans are fully initialized, so neither@ConfigPropertynor@ConfigMapping(EmulatorConfig) injection works — both causeSRCFG00027at 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.localwould incorrectly extractflocias a bucket name).Updates since last revision
@Inject EmulatorConfigapproach with programmaticConfigProvider.getConfig().getOptionalValue()— theEmulatorConfig@ConfigMappingbean also fails to inject in@PreMatchingfiltersType of change
fix:)AWS Compatibility
Incorrect behavior:
FLOCI_HOSTNAMEenv 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 fromEmulatorConfig.effectiveBaseUrl()is duplicated in the constructor (~3 lines). This is unavoidable since CDI injection is not available in@PreMatchingfilters; worth verifying the regex stays in sync.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 setFLOCI_HOSTNAME=myhostfor virtual-hosted-style to work. Path-style requests are unaffected.isAwsS3Domainfallback: Only coverss3.amazonaws.comands3.<region>.amazonaws.com. Other S3 endpoint patterns (e.g.s3-external-1.amazonaws.com) are not matched.FLOCI_HOSTNAME: The unit tests coverextractBucketwith variousbaseHostnamevalues, but there's no Quarkus integration test that setsFLOCI_HOSTNAMEas a config override and verifies end-to-end virtual-host routing.Checklist
./mvnw testpasses locallyLink to Devin session: https://app.devin.ai/sessions/06b7e28f3e664783b17ed18060e5c267
Requested by: @Meemaw