Skip to content

[spaceship] fix provisioning profile repair when certificates include nil#29935

Merged
iBotPeaches merged 4 commits into
fastlane:masterfrom
via-guy:fix/sigh-repair-nil-certificate-id
May 9, 2026
Merged

[spaceship] fix provisioning profile repair when certificates include nil#29935
iBotPeaches merged 4 commits into
fastlane:masterfrom
via-guy:fix/sigh-repair-nil-certificate-id

Conversation

@via-guy

@via-guy via-guy commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Problem

When a distribution certificate expires or is revoked all provisioning profiles become invalid. Running sigh repair crashes because the certificates are returned as nil, leading to the same error presented in #21295.

Summary

  • Prevent crash when provisioning profile certificates include nil (e.g. during sigh repair).
  • Filter/compact certificate ids before making the repair/update request and ensure certificate lists contain valid certificate objects.

Test plan

  • bundle exec rspec spaceship/spec/provisioning_profile_spec.rb

Fixes #21295

Avoid crashes during provisioning profile repair/update when certificate arrays include nil or non-certificate entries.

Made-with: Cursor
Refactor the certificate fallback logic to reduce nesting/complexity and satisfy rubocop metrics without changing behavior.

Made-with: Cursor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes sigh repair / ProvisioningProfile#update! crashing when provisioning profile certificate lists include nil entries (e.g., after a distribution cert expires/revokes), by sanitizing certificate/device IDs and improving certificate selection fallback behavior.

Changes:

  • Add logic to compact/filter invalid certificates and guard certificate_valid? against nil/blank IDs.
  • Refactor “pick a replacement certificate” logic into helper methods with Apple Development/Distribution fallbacks.
  • Add RSpec coverage for nil/compaction behavior around profile repair.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
spaceship/spec/provisioning_profile_spec.rb Adds specs around repairing profiles when certificate lists contain nil.
spaceship/lib/spaceship/portal/provisioning_profile.rb Filters/compacts certificate/device IDs, avoids nil.id crashes, and refactors certificate selection with fallback logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread spaceship/spec/provisioning_profile_spec.rb Outdated
Adjust provisioning profile repair spec to stub nil entries coming from profile details, matching real-world portal payloads.

Made-with: Cursor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spaceship/lib/spaceship/portal/provisioning_profile.rb Outdated
Comment thread spaceship/lib/spaceship/portal/provisioning_profile.rb Outdated
- Filter pre-populated certificates to Certificate instances instead of clearing all
- Raise when suggested_certificates is empty before repair (avoid opaque portal errors)
- Add spec for empty certificate selection; align inline comment with project style

Made-with: Cursor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@iBotPeaches iBotPeaches merged commit c91d22d into fastlane:master May 9, 2026
13 checks passed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @via-guy 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a month, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀"

PratikPatil131 pushed a commit to PratikPatil131/fastlane that referenced this pull request May 9, 2026
… nil (fastlane#29935)

* [spaceship] fix: handle nil certificates in provisioning profiles

Avoid crashes during provisioning profile repair/update when certificate arrays include nil or non-certificate entries.

Made-with: Cursor

* [spaceship] refactor: simplify certificate selection in update!

Refactor the certificate fallback logic to reduce nesting/complexity and satisfy rubocop metrics without changing behavior.

Made-with: Cursor

* [spaceship] test: cover nil certificate entries in profile_details

Adjust provisioning profile repair spec to stub nil entries coming from profile details, matching real-world portal payloads.

Made-with: Cursor

* [spaceship] address Copilot review on PR fastlane#29935

- Filter pre-populated certificates to Certificate instances instead of clearing all
- Raise when suggested_certificates is empty before repair (avoid opaque portal errors)
- Add spec for empty certificate selection; align inline comment with project style

Made-with: Cursor
@via-guy via-guy deleted the fix/sigh-repair-nil-certificate-id branch May 10, 2026 09:35

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Congratulations! 🎉 This was released as part of fastlane 2.234.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sigh repair fails with "undefined method `id' for nil:NilClass (NoMethodError) certificates.map(&:id)" with Apple Distribution certificate type

3 participants