Make timestamp required

Created on 24 October 2023, 8 months ago
Updated 30 January 2024, 5 months ago

Problem/Motivation

Currently the timestamp base field on Log entities is not required, but it is always populated with a default value if it is left blank.

Technically speaking, all logs MUST have a timestamp. It is a critical piece of their data architecture.

This came to my attention recently when users of farmOS pointed out that timestamp is not marked as required in the JSON Schema.

I tried to dig back in time to figure out why they weren't required, and I traced it to this issue: #3176676: Improvements on log storage and UI β†’

In that issue, we (at my direction, so I take the blame haha), removed setRequired(TRUE) because I said: "Make timestamp and state fields not required in form (timestamp will be autofilled)". We later rolled back the state field change.

Seeing that, I was worried that we were a bit stuck, because it might be a breaking change to make it required now. My thought was that if there were any users would pushed logs via API without timestamp (relying on the auto-populated timestamp), that code would break because it would require a timestamp be set. However, in testing this, I found that the default value gets populated *before* the check is performed, so it is *still* possible to submit a log without a timestamp, and it works exactly the same as before.

So as far as I can tell, this change would not break anything.

Proposed resolution

Add setRequired(TRUE) on timestamp base field.

Remaining tasks

Create MR.

User interface changes

Timestamp will be marked as required in log form UI.

API changes

Timestamp will be marked as required in JSON Schema when using JSON:API Schema module.

Data model changes

Timestamp will be required at the entity definition level.

πŸ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States m.stenta

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024