Skip to content

fix(publish): Replace unwrap() calls with error handling in provenance generation#31960

Open
Copilot wants to merge 5 commits intomainfrom
copilot/fix-deno-publish-ci-issue
Open

fix(publish): Replace unwrap() calls with error handling in provenance generation#31960
Copilot wants to merge 5 commits intomainfrom
copilot/fix-deno-publish-ci-issue

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

  • Identify all unwrap() calls in provenance.rs that can panic
  • Replace unwrap() at line 346 (transparency_logs.iter().next()) with proper error handling
  • Replace unwrap() at line 169 (rel_ref.find('@')) with proper error handling
  • Replace unwrap() calls for environment variables with better error messages
  • Update test to use proper GITHUB_WORKFLOW_REF format
  • Address code review feedback - replace unwrap_or_default() with proper error handling
  • Run code review - No issues found
  • Run CodeQL security check - No vulnerabilities found
  • Run rustfmt to fix formatting issues

Summary

Fixed panic in deno publish when running in CI containers by replacing all unwrap() calls in the provenance generation code with proper error handling. The changes ensure clear, actionable error messages are shown instead of panics.

Key changes:

  1. Line 359-362: Replaced transparency_logs.iter().next().unwrap() with ok_or_else() to provide clear error when Rekor returns no log entries
  2. Line 169-174: Replaced rel_ref.find('@').unwrap() with ok_or_else() to show which GITHUB_WORKFLOW_REF value is invalid
  3. Lines 163-190: Replaced all environment variable unwrap() calls with map_err() to show exactly which env var is missing
  4. Changed return types: Updated Predicate::new_github_actions() and ProvenanceAttestation::new_github_actions() to return Result<T, AnyError> to properly propagate errors
  5. Formatting: Applied rustfmt to ensure code follows project style guidelines

All code review and security checks passed with no issues.

Original prompt

This section details on the original issue you should resolve

<issue_title>Able to publish deno package locally but not from CI container</issue_title>
<issue_description>Deno v2.3.7 on x86_64-unknown-linux-gnu.

A panic occurred in Deno.

stack backtrace:

View trace: here

I was running the publish command on a forgejo runner in this container: code.forgejo.org/oci/node:20-bookworm</issue_description>

<agent_instructions>There is a panic caused by an unwrap somewhere in publish_provanance method. Remove unwraps and replace it will clear error messages.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@CLAassistant
Copy link

CLAassistant commented Jan 27, 2026

CLA assistant check
All committers have signed the CLA.

Copilot AI and others added 2 commits January 27, 2026 13:38
Co-authored-by: littledivy <34997667+littledivy@users.noreply.github.com>
Co-authored-by: littledivy <34997667+littledivy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix panic issue when publishing deno package from CI container fix(publish): Replace unwrap() calls with error handling in provenance generation Jan 27, 2026
Copilot AI requested a review from littledivy January 27, 2026 13:41
@bartlomieju bartlomieju marked this pull request as ready for review January 27, 2026 22:55
@bartlomieju
Copy link
Member

@copilot please run tools/format.js to ensure linting step passes correctly

Co-authored-by: bartlomieju <13602871+bartlomieju@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 30, 2026

@copilot please run tools/format.js to ensure linting step passes correctly

Done. Applied rustfmt formatting in commit e585c4d.

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.

Able to publish deno package locally but not from CI container

4 participants