Skip to content

Preventing deserialization errors in the case of missing flag maintainers #16

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/main/kotlin/com/procurify/flagcounter/FlagCounter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ class FlagCounter(
teamEmails: Set<TeamIdentifier>
): Map<TeamIdentifier, List<FlagDetail>> = flagDetails
.fold(mapOf<TeamIdentifier, List<FlagDetail>>().toMutableMap()) { acc, flagDetail ->
val emailIdentifier = TeamIdentifier(flagDetail.owner.email)
acc[emailIdentifier] = acc[emailIdentifier].orEmpty() + flagDetail
flagDetail.owner?.let { owner ->
val emailIdentifier = TeamIdentifier(owner.email)
acc[emailIdentifier] = acc[emailIdentifier].orEmpty() + flagDetail
}
acc
}
.filter { teamEmails.contains(it.key) }
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/procurify/flagcounter/FlagReader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface FlagReader {
*/
data class FlagDetail(
val key: String,
val owner: Owner,
val owner: Owner?,
val status: Status
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class LaunchDarklyFlagReader(
}?.let { status ->
FlagDetail(
key = flag.key,
owner = Owner(flag.maintainer.firstName, flag.maintainer.email),
owner = flag.maintainer?.let { Owner(it.firstName, it.email) },
status = if (status.name in listOf(LDStatus.LAUNCHED, LDStatus.INACTIVE)) {
Status.REMOVABLE
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data class LDFlagResponse(
data class LDFlagDetail(
val key: String,
@JsonProperty("_maintainer")
val maintainer: LDFlagMaintainer,
val maintainer: LDFlagMaintainer?,
@JsonProperty("_links")
val links: LDFlagLinks
)
Expand Down