Error adding program attribute

Hi - I am in the process of putting a program structure together on a DHIS2 test server and have come across this error

I am needing to assign a Tracked Entity Attribute for a Training Course Program


When attempting to save – the server is coming back with an error of :

Looking at the stack trace its giving the value –
“httpStatus”: “Internal Server Error”,
“httpStatusCode”: 500,
“status”: “ERROR”,
“message”: “could not execute statement”

I have looked into the DHIS2 logs - and the error seems to be coming from a relational link -

Caused by: org.postgresql.util.PSQLException: ERROR: null value in column “programattributeid” of relation “program_attributes” violates not-null constraint
May 06 12:14:46 hmis tomcat9[292]: Detail: Failing row contains (null, null, 1, f, 28025249, 28025515, 28019609, f, null, aJrNsG53Cmf, null, 2024-05-06 12:14:46.183, 2024-05-06 12:14:46.217, null, f, f, null).

I have filled in everything I can on the Tracked Entity Attribute - here is the XML of it:

"lastUpdated": "2024-05-06T14:23:53.972",
"id": "Z2Y0CPifIpb",
"href": "",
"created": "2024-05-06T14:15:38.424",
"name": "test",
"shortName": "test",
"code": "01",
"publicAccess": "rw------",
"generated": false,
"valueType": "TEXT",
"confidential": false,
"displayDescription": "01",
"displayFormName": "test",
"unique": false,
"favorite": false,
"dimensionItemType": "PROGRAM_ATTRIBUTE",
"aggregationType": "NONE",
"displayInListNoProgram": true,
"displayName": "test",
"pattern": "",
"description": "01",
"skipSynchronization": false,
"displayShortName": "test",
"externalAccess": false,
"displayOnVisitSchedule": false,
"orgunitScope": false,
"dimensionItem": "Z2Y0CPifIpb",
"inherit": false,
"optionSetValue": false,
"lastUpdatedBy": {
"displayName": "Matthew Burns Deas",
"name": "Matthew Burns Deas",
"id": "eBisM6ByZRK",
"username": "matthewdeas"
"sharing": {
"owner": "eBisM6ByZRK",
"userGroups": {},
"external": false,
"public": "rw------",
"users": {}
"access": {
"read": true,
"update": true,
"externalize": true,
"write": true,
"delete": true,
"manage": true
"createdBy": {
"displayName": "Matthew Burns Deas",
"name": "Matthew Burns Deas",
"id": "eBisM6ByZRK",
"username": "matthewdeas"
"user": {
"displayName": "Matthew Burns Deas",
"name": "Matthew Burns Deas",
"id": "eBisM6ByZRK",
"username": "matthewdeas"
"translations": [],
"userGroupAccesses": [],
"attributeValues": [],
"userAccesses": [],
"legendSets": [],
"favorites": []

Any help or suggestions? This is using DHIS v2.38.4


Hi @matthew_deas

This is most probably an issue that happened to your database. I’m not sure what caused it and whether there has been any recent changes or updates in your instance. I’m wondering when was the last time you updated your instance?

If you have a test instance (copy of the production instance), could you try to update the instance from 2.38.4 into 2.38.6 (.6 is the latest .38 patch version)? Maybe this will fix the tables.

It will help a lot if we can figure out how this issue came into being in the first place. Thanks!