Skip to content

Comments

Don't create entities with non-UUID IDs#7096

Open
seadowg wants to merge 15 commits intogetodk:masterfrom
seadowg:entity-uuid
Open

Don't create entities with non-UUID IDs#7096
seadowg wants to merge 15 commits intogetodk:masterfrom
seadowg:entity-uuid

Conversation

@seadowg
Copy link
Member

@seadowg seadowg commented Feb 13, 2026

Closes #7047

I've also added an experimental debug log.

Why is this the best possible solution? Were any other approaches considered?

I decided to move most of the validation we do for entities to the JavaRosa integration. This reduces the uncertainty we have to deal with in the code that creates offline entities and syncs with the server etc.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

There are no real changes other than to the entity create/update parts of the code, so only checks to those features are relevant

Before submitting this PR, please make sure you have:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

data class EntitiesExtra(val entities: List<FormEntity>)
data class EntitiesExtra(
val entities: List<FormEntity> = emptyList(),
val invalidEntities: List<InvalidEntity> = emptyList()
Copy link
Member Author

Choose a reason for hiding this comment

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

@lognaturel you've asked for this a few times and I figured this was a good time to give ourselves an API for exposing "invalid" entities. What's the leanest acceptable way you could see these being surfaced to make them useful?

Copy link
Member

@lognaturel lognaturel Feb 18, 2026

Choose a reason for hiding this comment

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

Summary of a brief conversation we had about this:

  • Start with exposing errors from debug builds only, maybe just storing in memory
  • Log Submission id, date time, path to the entity declaration, dataset, entity uuid if it exists, entity label if it exists
  • Longer term: audit log in the Project management Protected settings
  • Standard format for audit items, persisted in db or file
  • Send to Central automatically or on demand
  • Brainstorming doc

Copy link
Member Author

@seadowg seadowg Feb 24, 2026

Choose a reason for hiding this comment

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

Ok this will initially write out a log to debug.log in the project directory when the app is in debug mode. The line for an invalid entity will be:

${timestamp} Entities "Failed to create/update dataset=${it.dataset}, id=${it.id}, label=${it.label}"

We can definitely add more detail in, but I think this is a good start.


@OptIn(ExperimentalContracts::class)
fun String?.isV4UUID(): Boolean {
contract {
Copy link
Member Author

Choose a reason for hiding this comment

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

I've not used this before, but it's really cool! It's experimental, but used heavily within Kotlin's lib itself for methods like isNullOrBlank.

@seadowg seadowg marked this pull request as ready for review February 24, 2026 15:20
@seadowg seadowg requested a review from grzesiek2010 February 24, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't create/update offline entities without UUID id

2 participants