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
[BUGFIX] Replacing the occurrences of gen_range
with a safe alternative
#1754
Comments
@NishantJoshi00 I'm happy to take this one |
Hey @anupj, sure I'll assign it you! |
@NishantJoshi00 so if I understand the issue correctly. |
Hey Nishant,
Busy two work weeks, but i have book marked couple of evenings next week to resolve this. If its too late or is a blocker the feel free to reassign; i will pickup another issue next week. Sorry just poor timing on my behalf.
Anup
…On Thu, Aug 3, 2023 at 11:07, Pa1NarK ***@***.***(mailto:On Thu, Aug 3, 2023 at 11:07, Pa1NarK <<a href=)> wrote:
Hi ***@***.***(https://github.com/anupj), just checking in on the bug fix progress on GitHub. Any updates? Thanks!
—
Reply to this email directly, [view it on GitHub](#1754 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AABLJXU5OEGIHSZ3T36BVILXTNS57ANCNFSM6AAAAAA2QECXY4).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@pixincreate and @NishantJoshi00 i'm actively working on this issue this week so will reach out if I need help. Thanks for your patience. |
@NishantJoshi00 after making the changes when I run failures:
---- core::api_keys::tests::test_hashing_and_verification stdout ----
thread 'core::api_keys::tests::test_hashing_and_verification' panicked at 'called `Result::unwrap()` on an `Err` value: {"error":{"type":"server_not_available","code":"HE_00","message":"Something went wrong"}}
├╴at crates/router/src/core/api_keys.rs:47:18
├╴Failed to KMS decrypt API key hashing key
│
├─▶ Failed to KMS decrypt input data
│ ├╴at crates/external_services/src/kms.rs:82:14
│ ╰╴Failed to decrypt KMS value
│
╰─▶ failed to construct request
╰╴at crates/external_services/src/kms.rs:81:14', crates/router/src/core/api_keys.rs:564:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- types::storage::payment_attempt::tests::test_payment_attempt_mandate_field stdout ----
thread 'types::storage::payment_attempt::tests::test_payment_attempt_mandate_field' panicked at 'Failed to decrypt master enc key: Failed to KMS decrypt input data
├╴at crates/external_services/src/kms.rs:82:14
├╴Failed to decrypt KMS value
│
╰─▶ failed to construct request
╰╴at crates/external_services/src/kms.rs:81:14', crates/router/src/services.rs:264:14
---- types::storage::payment_attempt::tests::test_find_payment_attempt stdout ----
thread 'types::storage::payment_attempt::tests::test_find_payment_attempt' panicked at 'Failed to decrypt master enc key: Failed to KMS decrypt input data
├╴at crates/external_services/src/kms.rs:82:14
├╴Failed to decrypt KMS value
│
╰─▶ failed to construct request
╰╴at crates/external_services/src/kms.rs:81:14', crates/router/src/services.rs:264:14
failures:
core::api_keys::tests::test_hashing_and_verification
types::storage::payment_attempt::tests::test_find_payment_attempt
types::storage::payment_attempt::tests::test_payment_attempt_mandate_field
test result: FAILED. 48 passed; 3 failed; 1 ignored; 0 measured; 0 filtered out; finished in 3.24s Have you come across this before? I'm running all tests for the first time. |
Got it, i'll ignore these for now. thanks @pixincreate |
Hey @anupj, if the code that you'd like to test is not behind a feature gate, you can just run If it is indeed behind a feature gate and the feature is not one of |
Thanks @SanchithHegde When I run failures:
---- types::storage::payment_attempt::tests::test_find_payment_attempt stdout ----
thread 'types::storage::payment_attempt::tests::test_find_payment_attempt' panicked at 'called `Result::unwrap()` on an `Err` value: Timed out while trying to connect to the database
├╴at crates/router/src/connection.rs:118:10
│
╰─▶ Timed out in bb8
╰╴at crates/router/src/connection.rs:117:10', crates/router/src/types/storage/payment_attempt.rs:85:14
---- types::storage::payment_attempt::tests::test_payment_attempt_mandate_field stdout ----
thread 'types::storage::payment_attempt::tests::test_payment_attempt_mandate_field' panicked at 'called `Result::unwrap()` on an `Err` value: Timed out while trying to connect to the database
├╴at crates/router/src/connection.rs:118:10
│
╰─▶ Timed out in bb8
╰╴at crates/router/src/connection.rs:117:10', crates/router/src/types/storage/payment_attempt.rs:130:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
types::storage::payment_attempt::tests::test_find_payment_attempt
types::storage::payment_attempt::tests::test_payment_attempt_mandate_field
test result: FAILED. 49 passed; 2 failed; 1 ignored; 0 measured; 0 filtered out; finished in 10.17s Did I miss a step to setup a local database for testing? |
Description
Following up with the issue rust-random/rand#1326 created by @lsampras. The function
gen_range
in itself can cause panics and error handling isn't done for some cases. This is a unpredictable behaviour and needs to be replaced with a safe alternative which allows for error handling and recoverability.Objective
gen_range
while keeping the behaviour relatively samegen_range
with the decided safe alternativeGuidelines
The text was updated successfully, but these errors were encountered: