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

handle (panic) on missing payment chosen platform #2646

Conversation

staszek-krotki
Copy link
Contributor

No description provided.

@staszek-krotki staszek-krotki requested a review from a team as a code owner June 29, 2023 15:10
@staszek-krotki staszek-krotki force-pushed the staszek/yagna-2639/handle-missing-payment-chosen-platform branch from fb26018 to 23194ed Compare June 30, 2023 15:43
@pwalski pwalski self-requested a review July 6, 2023 11:40
Copy link
Contributor

@pwalski pwalski left a comment

Choose a reason for hiding this comment

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

Few nitpicks.

@@ -49,7 +48,7 @@ async fn create_allocation(
let payment_platform = allocation
.payment_platform
.clone()
.unwrap_or_else(|| DEFAULT_PAYMENT_PLATFORM.to_string());
.expect("payment platform not provided");
Copy link
Contributor

Choose a reason for hiding this comment

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

It panics on None. Please convert it to error response.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we even still need it after adding new Negotiator?

@@ -39,7 +38,7 @@ impl WriteObj {
let payment_platform = demand_properties
.pointer("/golem/com/payment/chosen-platform")
.as_typed(Value::as_str)
.unwrap_or(DEFAULT_PAYMENT_PLATFORM)
.expect("Demand property golem.com.payment.chosen-platform does not exist")
Copy link
Contributor

Choose a reason for hiding this comment

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

As before, it panics, so it should be either converted to Error or removed if unnecessary (because of new Negotiator).

Copy link
Contributor

@pwalski pwalski left a comment

Choose a reason for hiding this comment

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

I added some diffs to make it follow some common conventions like try_new when new returns Result, and I moved creation of DbError from constructor into the DAO.

staszek-krotki and others added 7 commits July 7, 2023 09:26
Co-authored-by: pwalski <4924911+pwalski@users.noreply.github.com>
Co-authored-by: pwalski <4924911+pwalski@users.noreply.github.com>
Co-authored-by: pwalski <4924911+pwalski@users.noreply.github.com>
Co-authored-by: pwalski <4924911+pwalski@users.noreply.github.com>
Co-authored-by: pwalski <4924911+pwalski@users.noreply.github.com>
Copy link
Contributor

@pwalski pwalski left a comment

Choose a reason for hiding this comment

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

Please squash commits (or cleanup history and I will approve again (but squash merge will be fine)).

@staszek-krotki staszek-krotki merged commit 5a68e2d into master Jul 7, 2023
14 checks passed
@staszek-krotki staszek-krotki deleted the staszek/yagna-2639/handle-missing-payment-chosen-platform branch July 7, 2023 09:28
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.

New error handling for lack of golem.com.payment.chosen-platform
2 participants