-
Notifications
You must be signed in to change notification settings - Fork 143
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(artifact): more resilient app version parsing #948
fix(artifact): more resilient app version parsing #948
Conversation
val appversion = AppVersion.parseName(version) | ||
if (appversion?.version != null) { | ||
summary = summary.copy(displayName = appversion.version) | ||
} | ||
if (appversion?.buildNumber != null) { | ||
summary = summary.copy(build = BuildMetadata(id = appversion.buildNumber.toInt())) | ||
} | ||
if (appversion?.commit != null) { | ||
summary = summary.copy(git = GitMetadata(commit = appversion.commit)) | ||
} | ||
summary |
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.
I'm failing to see how this is different from what you had before, other than setting displayName
outside this block above. I find this format harder to read than the one with the property names and inline if statements to the left. It's also potentially copying the whole object 3 times over which I know is not a huge deal but I feel if we just let these spread they may become a problem.
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.
I believe the current problem is that appversion.buildNumber
is null for one of the artifacts, so the appversion.buildNumber.toInt()
call fails on line 162. In the new implementation, this call is guarded by a null chcek in line 169.
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.
Lorin is correct. Again, this code should be replaced in Q2.
I'd love to see a unit test against the problematic artifact version to verify that the code no longer throws an exception on it. |
// todo: replace, this is brittle | ||
val appversion = AppVersion.parseName(version) | ||
if (appversion?.version != null) { | ||
summary = summary.copy(displayName = appversion.version) |
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.
Do we ever expect fields of appversion
to be null during normal operation? If not, if this if
check fails, I'd put a WARN
level log statement with the value of theversion
function argument to make it easier to debug in the future.
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.
we might fail, we might not fail if that's the case. it definitely puts us into a weird state. once we pull the appversion off the ami though it shouldn't be null. we don't rely on any of the other fields that i'm using here (if i remember correctly). Logging would probably be helpful, you're right.
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.
I made comments, but would like to see this get out to put us back in a good state.
This PR name might lead you to think that this is less hacky than before. It's not. It's just more wacky-input-safe.