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 nil ptr in deal status command #685

Merged
merged 2 commits into from
Aug 11, 2022
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
26 changes: 14 additions & 12 deletions cmd/boost/deal_status_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,21 @@ var dealStatusCmd = &cli.Command{
return fmt.Errorf("send deal status request failed: %w", err)
}

label := resp.DealStatus.Proposal.Label
var lstr string
if label.IsString() {
lstr, err = label.ToString()
if err != nil {
lstr = "could not marshall deal label"
}
} else {
lbz, err := label.ToBytes()
if err != nil {
lstr = "could not marshall deal label"
if resp != nil && resp.DealStatus != nil {
label := resp.DealStatus.Proposal.Label
if label.IsString() {
lstr, err = label.ToString()
if err != nil {
lstr = "could not marshall deal label"
}
} else {
lstr = "bytes: " + hex.EncodeToString(lbz)
lbz, err := label.ToBytes()
if err != nil {
lstr = "could not marshall deal label"
} else {
lstr = "bytes: " + hex.EncodeToString(lbz)
}
}
}

Expand All @@ -115,7 +117,7 @@ var dealStatusCmd = &cli.Command{
// resp.DealStatus should always be present if there's no error,
// but check just in case
if resp.DealStatus != nil {
out["label"] = label
out["label"] = lstr
out["chainDealId"] = resp.DealStatus.ChainDealID
out["status"] = resp.DealStatus.Status
out["publishCid"] = nil
Expand Down