Skip to content

Code audit: fail-loud when FOOD_API_KEY is missing at build time#4

Merged
jumincho merged 1 commit into
mainfrom
claude/code-audit-fixes
May 27, 2026
Merged

Code audit: fail-loud when FOOD_API_KEY is missing at build time#4
jumincho merged 1 commit into
mainfrom
claude/code-audit-fixes

Conversation

@jumincho
Copy link
Copy Markdown
Owner

Summary

Audit caught that the previous Gradle config silently defaulted foodApiKey to "" when neither local.properties nor any env var supplied it. The APK compiled fine but then threw 401 from the Food Safety OpenAPI at runtime — a confusing, late-binding failure that's harder to debug than a build error.

Changes

  • app/build.gradle: throws GradleException at configure time when FOOD_API_KEY is missing, with a remediation message that points users to local.properties and the README build section.
  • Also extends the lookup to System.getenv('FOOD_API_KEY'), so CI / release pipelines can inject the key without touching local.properties.

Test plan

  • CI Verify passes (it doesn't invoke gradle, so this fail-fast doesn't break it)
  • ./gradlew assembleDebug without any FOOD_API_KEY source fails fast with the new message
  • ./gradlew assembleDebug with the key in local.properties builds normally

Generated by Claude Code

Audit caught that the previous Gradle config silently defaulted
foodApiKey to "" when neither local.properties nor any env var
supplied it. That produced an APK that compiled fine but threw
401 from the Food Safety OpenAPI at runtime — a confusing,
late-binding failure mode.

Now the build throws a GradleException at configure time with
the exact remediation message (local.properties entry or env
var) and a pointer to the README's build section.

Also extends the lookup to System.getenv('FOOD_API_KEY'), so a
CI/release pipeline can inject the key without touching
local.properties.
@jumincho jumincho merged commit fbb3509 into main May 27, 2026
1 check passed
@jumincho jumincho deleted the claude/code-audit-fixes branch May 27, 2026 03:56
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