Skip to content

Conversation

@pm-dimagi
Copy link
Contributor

@pm-dimagi pm-dimagi commented May 6, 2025

Product Description

Bug fixes
https://dimagi.atlassian.net/browse/QA-7728
QA-7729
QA-7730
QA-7727
QA-7707
cross-request:dimagi/commcare-core#1475

Technical Summary

Feature Flag

Safety Assurance

Safety story

Automated test coverage

QA Plan

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

String dailyFinish = getDailyFinishTime();

if (dailyStart.length() == 0 || dailyFinish.length() == 0) {
if (dailyStart == "null" || dailyFinish == "null" || dailyStart.isEmpty() || dailyFinish.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We're pushing back on doing these checks in mobile code, and instead requiring server fixes when we find they're sending the "null" string. This may have been addressed already in recent server work but if not let's submit a new ticket for them to fix it and remove the check for "null" here. @shubham1g5 Your thoughts on checking for empty string here? We just want null, correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Think empty checks are fine to do but not "null" String checks as they seems like a server mishandling of data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

String dailyFinish = getDailyFinishTime();

if (dailyStart.length() == 0 || dailyFinish.length() == 0) {
if (dailyStart == "null" || dailyFinish == "null" || dailyStart.isEmpty() || dailyFinish.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Think empty checks are fine to do but not "null" String checks as they seems like a server mishandling of data.

Comment on lines 191 to 193
private String safeString(JSONObject obj, String key) {
return obj.isNull(key) ? "" : obj.optString(key);
}
Copy link
Contributor

@shubham1g5 shubham1g5 May 7, 2025

Choose a reason for hiding this comment

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

  • can we make this an Kotlin extension function so that it's accessible to other classes.
  • Also can we reply with null instead with empty string there as that's more correct representation of the data being sent.
  • call this optStringSafe instead to signify it's a wrapper over optString

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pm-dimagi pm-dimagi requested a review from shubham1g5 May 7, 2025 14:29

fun JSONObject.optStringSafe(key: String): String? {
val value = this.optString(key, null)
return if (this.isNull(key) || value == "null") null else value
Copy link
Contributor

Choose a reason for hiding this comment

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

does isNull doesn't check for "null" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 228 to 229
job.dailyStartTime = JsonExtensions.optStringSafe(flags, META_DAILY_START_TIME) != null
? JsonExtensions.optStringSafe(flags, META_DAILY_START_TIME) : "";
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just pass the empty string fallback to optStringSafe itself as an argument and have the fallback pass through further to optString

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pm-dimagi pm-dimagi requested a review from shubham1g5 May 7, 2025 14:49
Comment on lines 9 to 10
val value = fallback?.let { this.optString(key, it) }
return value ?: fallback
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we just change it to this.optString(key, fallback) irrespective of whether fallback is null or not ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 228 to 230
job.dailyStartTime =
JsonExtensions.optStringSafe(flags, META_DAILY_START_TIME, "");
job.dailyFinishTime = JsonExtensions.optStringSafe(flags, META_DAILY_FINISH_TIME, "");
Copy link
Contributor

Choose a reason for hiding this comment

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

can use some formatting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pm-dimagi pm-dimagi merged commit e49487d into pm_beta_relase_472005 May 7, 2025
1 check passed
String dailyFinish = getDailyFinishTime();

if (dailyStart.length() == 0 || dailyFinish.length() == 0) {
if (dailyStart == null || dailyFinish == null || dailyStart.isEmpty() || dailyFinish.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: You could use Strings.isNullOrEmpty() here to simplify this slightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants