Skip to content

fix: honor android sdk mirror url - #10

Merged
jdx merged 1 commit into
mainfrom
codex/fix-android-sdk-mirror-url
Jul 16, 2026
Merged

fix: honor android sdk mirror url#10
jdx merged 1 commit into
mainfrom
codex/fix-android-sdk-mirror-url

Conversation

@jdx

@jdx jdx commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

  • read ANDROID_SDK_MIRROR_URL from the process environment in both version discovery and pre-install hooks
  • resolve metadata and relative download URLs against the configured mirror
  • add a mocked-hook regression test covering both hooks
  • run unit tests with Lua in CI so hook behavior and syntax are actually exercised

Root cause

The hooks attempted to read the variable from the vfox env module, where it was always nil. The vfox runtime exposes process environment variables through os.getenv.

Validation

  • mise x stylua@latest -- stylua --check metadata.lua hooks test/mirror_url.lua
  • mise x actionlint@latest -- actionlint .github/workflows/test.yml
  • mise x lua@5.4 -- ./test/run.sh

Resolves #6.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the custom env module with os.getenv to retrieve the ANDROID_SDK_MIRROR_URL environment variable in both available.lua and pre_install.lua hooks. It also introduces a new test script (test/mirror_url.lua) and integrates it into the test suite (test/run.sh) to verify mirror URL handling. Feedback suggests normalizing the base_url by stripping any trailing slashes to prevent double slashes when constructing URLs.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread hooks/available.lua
local env = require("env")

local base_url = env.ANDROID_SDK_MIRROR_URL or "https://dl.google.com/android/repository"
local base_url = os.getenv("ANDROID_SDK_MIRROR_URL") or "https://dl.google.com/android/repository"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If the user configures ANDROID_SDK_MIRROR_URL with a trailing slash (e.g., https://mirror.example/android/), appending /repository2-3.xml will result in a URL with double slashes (https://mirror.example/android//repository2-3.xml). Some strict HTTP servers or proxies might reject this or return a 404.

It is safer to normalize the base_url by stripping any trailing slashes.

    local base_url = (os.getenv("ANDROID_SDK_MIRROR_URL") or "https://dl.google.com/android/repository"):gsub("/+$", "")

Comment thread hooks/pre_install.lua
end

local base_url = env.ANDROID_SDK_MIRROR_URL or "https://dl.google.com/android/repository"
local base_url = os.getenv("ANDROID_SDK_MIRROR_URL") or "https://dl.google.com/android/repository"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If the user configures ANDROID_SDK_MIRROR_URL with a trailing slash, appending /repository2-3.xml or / followed by the relative URL will result in double slashes. Normalizing the base_url by stripping trailing slashes ensures robust URL construction.

    local base_url = (os.getenv("ANDROID_SDK_MIRROR_URL") or "https://dl.google.com/android/repository"):gsub("/+$", "")

@jdx
jdx merged commit 26bdad1 into main Jul 16, 2026
4 checks passed
@jdx
jdx deleted the codex/fix-android-sdk-mirror-url branch July 16, 2026 21:07
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.

Failed to set env ANDROID_SDK_MIRROR_URL

1 participant