Skip to content

fix: allow --use-version artifact downloads without GitHub token#2212

Open
osterman wants to merge 5 commits intomainfrom
osterman/public-artifact-fetch
Open

fix: allow --use-version artifact downloads without GitHub token#2212
osterman wants to merge 5 commits intomainfrom
osterman/public-artifact-fetch

Conversation

@osterman
Copy link
Member

@osterman osterman commented Mar 16, 2026

what

  • Allow unauthenticated artifact downloads for public repositories via --use-version flag
  • Metadata fetching (PR info, workflow runs, artifact listing) and artifact downloads now work without authentication on public repos per GitHub API docs
  • Replace upfront GetGitHubTokenOrError() gate with optional GetGitHubToken() in InstallFromPR() and InstallFromSHA()
  • Skip Authorization header when token is unavailable in downloadPRArtifact()
  • Add smart HTTP error handling with buildDownloadHTTPError() to distinguish auth failures from rate limiting

why

  • Users without GitHub token environment variables couldn't install PR artifacts, even for public repositories
  • Rate limit errors (429) were reported generically as "HTTP 429" with no actionable context
  • Need to properly surface rate limit information (60/hr for unauthenticated, 5,000/hr for authenticated) to guide users

references

  • Fixes the issue where atmos --use-version=2129 fails with "authentication failed" when no GITHUB_TOKEN is set
  • GitHub API documentation confirms artifact downloads work without authentication for public repositories

Summary by CodeRabbit

  • New Features
    • GitHub authentication is now optional; public repositories can be downloaded without a token.
    • Enhanced error messages for artifact downloads that distinguish authentication failures, rate limits, and other HTTP errors.

…nd other YAML functions (#2207)

* updates

* fix: derive stack name for locals so !terraform.state works (#2080)

The 2-arg form of !terraform.state in locals failed with "stack is
required" because extractLocalsFromRawYAML passed an empty string as
the current stack. Add deriveStackNameForLocals() and
computeStackFileName() to derive the stack name from the file path,
vars, and atmos config before processing locals.

Includes unit tests with mock StateGetter, integration tests for Go
template conditionals with !env, a new locals-conditional fixture,
and comprehensive architecture documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Update locals example to showcase all features concisely

Add Sprig functions (pipe upper), multiple components (myapp-worker
with suffixed full_name), and file-scoped isolation commentary.
Update README with feature sections and try-it commands.
Add TestExampleLocalsWorkerComponent test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Update locals documentation with processing pipeline and YAML function details

Add comprehensive documentation for locals processing pipeline, cross-component
references with !terraform.state, environment variable conditionals with !env,
and updated best practices.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* update docs

* [autofix.ci] apply automated fixes

* Fix broken link and add Gomplate/Atmos template function references in locals docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Improve test coverage and address PR review feedback

- Handle .yaml.tmpl/.yml.tmpl extensions in computeStackFileName (longest suffix first)
- Add test cases for .yaml.tmpl, .yml.tmpl, no extension, and unknown extension
- Use filepath.Join() for all test paths (cross-platform compliance)
- Fix absible → ansible typo in locals docs
- Fix misleading comment in dev.yaml example
- Fix override semantics contradiction in fix doc

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Address PR review: fix test count, remove ansible from locals scopes

- Update TestComputeStackFileName case count from 4 to 8 in fix doc
- Remove ansible from locals pipeline/scope docs (only terraform/helmfile/packer supported)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@osterman osterman requested review from a team as code owners March 16, 2026 18:34
@github-actions github-actions bot added the size/l Large size PR label Mar 16, 2026
@osterman osterman added the patch A minor, backward compatible change label Mar 16, 2026
@mergify
Copy link

mergify bot commented Mar 16, 2026

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify bot added the needs-cloudposse Needs Cloud Posse assistance label Mar 16, 2026
@github-actions
Copy link

github-actions bot commented Mar 16, 2026

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

The aws.github.io/aws-sdk-go-v2 site is no longer available (returns 404).
Update the reference to point to the pkg.go.dev canonical documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5172d489-5a09-4a27-b476-232dbbee87c6

📥 Commits

Reviewing files that changed from the base of the PR and between 07c2b54 and 15a9c2a.

📒 Files selected for processing (1)
  • pkg/toolchain/pr_artifact_test.go

📝 Walkthrough

Walkthrough

The changes introduce optional GitHub token authentication for artifact downloads in the Go toolchain. Token retrieval is now non-blocking, allowing public repository flows to proceed without authentication. A new error builder improves HTTP failure diagnostics. Documentation is updated to reflect unauthenticated access capability.

Changes

Cohort / File(s) Summary
Documentation & API Updates
docs/prd/auth-context-multi-identity.md, pkg/github/artifacts.go
AWS SDK reference link updated; GetPRHeadSHA signature expanded with optional token parameter; method documentation clarified to reflect unauthenticated access for public repos.
Token Handling & Error Management
pkg/toolchain/pr_artifact.go, pkg/toolchain/sha_artifact.go
Token retrieval changed from required (GetGitHubTokenOrError) to optional (GetGitHubToken), allowing execution without auth. New buildDownloadHTTPError helper provides context-aware HTTP error handling for auth failures and rate limits. Authorization header only set when token present.
Test Coverage
pkg/toolchain/pr_artifact_test.go
Comprehensive HTTP-related test suite added: validates buildDownloadHTTPError mapping, successful downloads with/without tokens, authorization header behavior, authentication errors, and rate limit handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • aknysh
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.97% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the core change: enabling artifact downloads without GitHub token authentication for public repositories.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch osterman/public-artifact-fetch
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
examples/locals/components/terraform/myapp/main.tf (1)

36-50: Outputs look fine for demo purposes.

The outputs are straightforward passthrough values. For a mock component in the examples directory, this is adequate. If you want consistency with the variable definitions, you could add description attributes to the outputs, but it's optional for fixture code.

💡 Optional: Add descriptions to outputs for consistency
 output "name" {
+  description = "Application name"
   value = var.name
 }

 output "full_name" {
+  description = "Full application name (computed from locals)"
   value = var.full_name
 }

 output "deploy_target" {
+  description = "Deployment target (computed from conditional locals)"
   value = var.deploy_target
 }

 output "tags" {
+  description = "Resource tags (computed from locals)"
   value = var.tags
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/locals/components/terraform/myapp/main.tf` around lines 36 - 50,
Outputs in main.tf are plain passthroughs and the reviewer suggested optionally
adding descriptions for consistency; update the output blocks for name,
full_name, deploy_target, and tags to include a description attribute (e.g.,
description = "Component name", "Full name of the component", "Deployment
target", "Tags map/list") so each output block (output "name", output
"full_name", output "deploy_target", output "tags") includes a descriptive
string matching the intent of the corresponding variable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@examples/locals/components/terraform/myapp/main.tf`:
- Around line 36-50: Outputs in main.tf are plain passthroughs and the reviewer
suggested optionally adding descriptions for consistency; update the output
blocks for name, full_name, deploy_target, and tags to include a description
attribute (e.g., description = "Component name", "Full name of the component",
"Deployment target", "Tags map/list") so each output block (output "name",
output "full_name", output "deploy_target", output "tags") includes a
descriptive string matching the intent of the corresponding variable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e4b7cc25-304e-46f0-b61b-a425b0d3e8c9

📥 Commits

Reviewing files that changed from the base of the PR and between c9f5f50 and 07c2b54.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (23)
  • NOTICE
  • docs/fixes/2026-03-15-locals-terraform-state-missing-stack-context.md
  • docs/prd/auth-context-multi-identity.md
  • examples/locals/README.md
  • examples/locals/components/terraform/myapp/main.tf
  • examples/locals/stacks/deploy/dev.yaml
  • examples/locals/stacks/deploy/prod.yaml
  • examples/quick-start-advanced/Dockerfile
  • go.mod
  • internal/exec/stack_processor_utils.go
  • internal/exec/stack_processor_utils_test.go
  • internal/terraform_backend/terraform_backend_s3.go
  • pkg/ai/analyze/analyze_test.go
  • pkg/devcontainer/lifecycle_rebuild_test.go
  • pkg/github/artifacts.go
  • pkg/toolchain/pr_artifact.go
  • pkg/toolchain/sha_artifact.go
  • tests/cli_locals_test.go
  • tests/fixtures/scenarios/locals-conditional/atmos.yaml
  • tests/fixtures/scenarios/locals-conditional/components/terraform/mock/main.tf
  • tests/fixtures/scenarios/locals-conditional/stacks/deploy/pr-empty.yaml
  • tests/fixtures/scenarios/locals-conditional/stacks/deploy/pr-set.yaml
  • website/docs/stacks/locals.mdx
💤 Files with no reviewable changes (1)
  • internal/terraform_backend/terraform_backend_s3.go

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 16, 2026
@github-actions github-actions bot added size/s Small size PR and removed size/l Large size PR labels Mar 16, 2026
@osterman
Copy link
Member Author

@copilot this looks like a dirty merge update. It's showing thousands of lines changed, even though it was just a simple change.

Copy link
Contributor

Copilot AI commented Mar 16, 2026

@osterman I've opened a new pull request, #2213, to work on those changes. Once the pull request is ready, I'll request review from you.

@osterman osterman closed this Mar 16, 2026
@mergify mergify bot removed the needs-cloudposse Needs Cloud Posse assistance label Mar 16, 2026
@osterman osterman reopened this Mar 16, 2026
@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.91%. Comparing base (e0dc13b) to head (e19ba36).

Files with missing lines Patch % Lines
pkg/toolchain/pr_artifact.go 94.28% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2212      +/-   ##
==========================================
+ Coverage   76.83%   76.91%   +0.07%     
==========================================
  Files        1001     1001              
  Lines       95361    95383      +22     
==========================================
+ Hits        73274    73363      +89     
+ Misses      17820    17746      -74     
- Partials     4267     4274       +7     
Flag Coverage Δ
unittests 76.91% <94.44%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/github/artifacts.go 83.70% <ø> (+7.30%) ⬆️
pkg/toolchain/sha_artifact.go 75.59% <100.00%> (+2.72%) ⬆️
pkg/toolchain/pr_artifact.go 65.47% <94.28%> (+9.70%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Cover all HTTP error branches (401/403/429/5xx) with and without tokens,
and verify downloadPRArtifact sends auth headers only when token is set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added size/m Medium size PR and removed size/s Small size PR labels Mar 16, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 16, 2026
@mergify
Copy link

mergify bot commented Mar 17, 2026

💥 This pull request now has conflicts. Could you fix it @osterman? 🙏

@mergify mergify bot added the conflict This PR has conflicts label Mar 17, 2026
…act-fetch

# Conflicts:
#	docs/prd/auth-context-multi-identity.md
@mergify mergify bot removed the conflict This PR has conflicts label Mar 17, 2026
@osterman osterman added this to the 1.211.0 milestone Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants