Skip to content

fix(services/github): support env-driven construction, honor range reads, add read-only behavior tests - #8010

Open
trim21 wants to merge 4 commits into
apache:mainfrom
trim21:test-github-read-only
Open

fix(services/github): support env-driven construction, honor range reads, add read-only behavior tests#8010
trim21 wants to merge 4 commits into
apache:mainfrom
trim21:test-github-read-only

Conversation

@trim21

@trim21 trim21 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

None.

Rationale for this change

Three related gaps block the github service from having behavior test coverage and working correctly with a token:

  • GithubConfig::from_uri requires owner and repo to be parsed from the URI authority, which breaks Operator::via_iter("github", ...) construction used by env-driven setups and the behavior test framework. The github service is the only service that cannot be configured through environment variables.
  • GitHub ignores the Range header on authenticated Contents API requests and returns the full content with 200, so range reads (.range() / suffix reads) return too much data when a token is configured.
  • The service has no behavior tests, which is why it stayed excluded from bindings.

What changes are included in this PR?

  • Fix from_uri to fall back to options (OPENDAL_GITHUB_OWNER / OPENDAL_GITHUB_REPO) when the URI has no authority or path; github://<owner>/<repo>/<root> URI semantics are unchanged. Owner and repo stay validated as non-empty since #[serde(default)] would otherwise silently turn a missing field into an empty string.
  • Fix range reads: when the server returns 200 (ignored range) instead of 206, slice the response client-side, matching the pattern used by etcd/sled/postgresql.
  • Add .github/services/github/read_only/action.yml that runs the read-only behavior tests against the fixtures in core/tests/data of the apache/opendal repository itself, so no extra backend or credentials are required.
  • Inject GITHUB_TOKEN into the core and python binding behavior test steps so the github tests can raise their API rate limit.
  • Add unit tests covering option-driven construction.

Once merged, the behavior test matrix for core and all language bindings automatically picks up the github case.

Reproduction

repro_github_range.sh demonstrates the Range behavior difference (requires gh and curl):

  • Anonymous request: 206 with content-range: bytes 1024-2047/30482 (1024 bytes).
  • Authenticated request (gh auth token): 200 with the full 30482-byte content — the Range header is ignored.

Are there any user-facing changes?

OPENDAL_GITHUB_OWNER / OPENDAL_GITHUB_REPO environment variables now work for configuring the github service, and range reads work correctly when a token is configured.

AI Usage Statement

This PR was developed with the assistance of an AI coding agent (pi) for implementation, testing, and PR preparation; the changes were reviewed by the author.

@trim21
trim21 requested review from Xuanwo and tisonkun as code owners August 1, 2026 15:25
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 1, 2026
@trim21
trim21 marked this pull request as draft August 1, 2026 15:26
trim21 added 2 commits August 1, 2026 23:27
GithubConfig::from_uri requires owner and repo to be parsed from the URI
authority, which breaks Operator::via_iter("github", env) construction
used by the behavior tests and env-driven setups. Fall back to options
when the URI has no authority or path.
Run the existing read-only behavior tests against the fixtures in
core/tests/data of the apache/opendal repository. Forward the workflow
GITHUB_TOKEN to raise the GitHub API rate limit.
@trim21
trim21 force-pushed the test-github-read-only branch from f5f2cb2 to 4d86abe Compare August 1, 2026 15:27
@trim21 trim21 changed the title test(services/github): add read-only behavior tests fix(services/github): support env-driven construction and add read-only behavior tests Aug 1, 2026
@trim21 trim21 changed the title fix(services/github): support env-driven construction and add read-only behavior tests fix(services/github): support env-driven construction, honor range reads, add read-only behavior tests Aug 1, 2026
GitHub ignores the Range header on authenticated Contents API requests
and returns the full content with 200 instead of 206. Slice the response
client-side when the server did not honor the requested range, matching
the pattern used by other services.
@trim21
trim21 marked this pull request as ready for review August 1, 2026 15:50
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. releases-note/fix The PR fixes a bug or has a title that begins with "fix" and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/fix The PR fixes a bug or has a title that begins with "fix" size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant