Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(panic): gracefully handle if we can't find a Release #189

Merged
merged 1 commit into from
Oct 18, 2024
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
30 changes: 21 additions & 9 deletions peridot/builder/v1/workflow/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ import (
"encoding/hex"
"errors"
"fmt"
"io"
http2 "net/http"
"net/url"
"os"
"path/filepath"
"regexp"
"strings"
"time"

"github.com/go-git/go-billy/v5"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-billy/v5/osfs"
Expand All @@ -62,19 +71,11 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/wrapperspb"
"io"
http2 "net/http"
"net/url"
"os"
"path/filepath"
"peridot.resf.org/apollo/rpmutils"
"peridot.resf.org/peridot/db/models"
peridotpb "peridot.resf.org/peridot/pb"
"peridot.resf.org/peridot/rpmbuild"
"peridot.resf.org/utils"
"regexp"
"strings"
"time"
)

// This should probably reside somewhere else
Expand Down Expand Up @@ -1016,12 +1017,23 @@ func (c *Controller) srpmprocToImportRevisions(project *models.Project, pkg stri
moduleStream = true
}

version := res.BranchVersions[branch]
version, ok := res.BranchVersions[branch]

if !ok {
c.log.Errorf("unable to find branch %s in BranchVersions", branch)
}

if version == nil {
c.log.Errorf("version for branch %s is nil", branch)
}

// For now let's just include all module metadata in the release field.
// We might use it to match upstream versions in the Future.
// If it doesn't work out as expected, we can always resort back to replacing.
release := version.Release
if release == "" {
c.log.Errorf("release information missing for branch %s", branch)
}

section := OpenPatchRpms
if module {
Expand Down