-
Notifications
You must be signed in to change notification settings - Fork 94
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(crons): Limit environment names on check-ins to 64 chars #2309
Merged
Merged
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b35cfce
fix(crons): Limit environment names on check-ins to 64 chars
rjo100 8674f5b
added changelog
rjo100 bc674bc
import env length
rjo100 2d84859
Update relay-monitors/src/lib.rs
rjo100 e34fe1c
Merge branch 'master' into rjo100/max-chars-environment-checkin
rjo100 a882300
fix submodule
rjo100 d23dffc
feedback fixes
rjo100 6efe2ee
Merge branch 'master' into rjo100/max-chars-environment-checkin
rjo100 0ec26cb
hardcode env limit
rjo100 1c5574e
Merge branch 'master' into rjo100/max-chars-environment-checkin
rjo100 0fbec16
optional check
rjo100 461c26a
fix function
rjo100 f539f3c
as ref
rjo100 e2989cb
unwrap
rjo100 9626e42
as ref 2
rjo100 38d5b75
pass link
rjo100 9cc6de8
Fix
evanpurkhiser 51223e8
Merge branch 'master' into rjo100/max-chars-environment-checkin
rjo100 49ffa75
fix test
evanpurkhiser d88be2d
Merge branch 'master' into rjo100/max-chars-environment-checkin
rjo100 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,6 +22,9 @@ use serde::{Deserialize, Serialize}; | |||||
/// Maximum length of monitor slugs. | ||||||
const SLUG_LENGTH: usize = 50; | ||||||
|
||||||
/// Maximum length of environment names. | ||||||
const ENVIRONMENT_LENGTH: usize = MaxChars::Environment.limit(); | ||||||
|
||||||
/// Error returned from [`process_check_in`]. | ||||||
#[derive(Debug, thiserror::Error)] | ||||||
pub enum ProcessCheckInError { | ||||||
|
@@ -32,6 +35,10 @@ pub enum ProcessCheckInError { | |||||
/// Monitor slug was empty after slugification. | ||||||
#[error("the monitor slug is empty or invalid")] | ||||||
EmptySlug, | ||||||
|
||||||
/// Environment name was invalid.environment. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
#[error("the environment is invalid")] | ||||||
InvalidEnvironment, | ||||||
} | ||||||
|
||||||
/// | ||||||
|
@@ -160,6 +167,10 @@ pub fn process_check_in(payload: &[u8]) -> Result<Vec<u8>, ProcessCheckInError> | |||||
return Err(ProcessCheckInError::EmptySlug); | ||||||
} | ||||||
|
||||||
if check_in.environment.chars().count() > ENVIRONMENT_LENGTH { | ||||||
return Err(ProcessCheckInError::InvalidEnvironment); | ||||||
} | ||||||
|
||||||
Ok(serde_json::to_vec(&check_in)?) | ||||||
} | ||||||
|
||||||
|
@@ -285,4 +296,20 @@ mod tests { | |||||
let result = process_check_in(json.as_bytes()); | ||||||
assert!(matches!(result, Err(ProcessCheckInError::EmptySlug))); | ||||||
} | ||||||
|
||||||
#[test] | ||||||
fn process_invalid_environment() { | ||||||
let json = r#"{ | ||||||
"check_in_id": "a460c25ff2554577b920fcfacae4e5eb", | ||||||
"monitor_slug": "test", | ||||||
"status": "in_progress" | ||||||
"environment": "1234567890123456789012345678901234567890123456789012345678901234567890" | ||||||
}"#; | ||||||
|
||||||
let result = process_check_in(json.as_bytes()); | ||||||
assert!(matches!( | ||||||
result, | ||||||
Err(ProcessCheckInError::InvalidEnvironment) | ||||||
)); | ||||||
} | ||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you, please, move this to
Unreleased
section of the changelogThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, got moved during a bad merge