Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/attestation/crafter/crafter.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,14 @@ func (c *Crafter) ResolveEnvVars(ctx context.Context, attestationID string) erro

// AutoCollectPRMetadata automatically collects PR/MR metadata if running in a PR/MR context
func (c *Crafter) AutoCollectPRMetadata(ctx context.Context, attestationID string, runner SupportedRunner, casBackend *casclient.CASBackend) error {
if err := c.requireStateLoaded(); err != nil {
return fmt.Errorf("crafting state not loaded before inspecting PR/MR metadata: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

can this ever happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

My take is that since it’s a public method on the crafter, it’s not guaranteed that it’s being called after a state has been loaded. Similarly, the other public methods that interact with the state have the guard, so I’ve added it here as well.

}

if err := c.LoadCraftingState(ctx, attestationID); err != nil {
c.Logger.Warn().Err(err).Msg("failed to reload crafting state")
}

// Detect if we're in a PR/MR context
isPR, metadata, err := DetectPRContext(runner)
if err != nil {
Expand Down
Loading