Select to view content in your preferred language

Unexplained error when updating hosted feature layer domains: "{'code': 500, 'message': "ERROR: Domain does not exist: '㛨㫀ȃ'", 'details': []}"

52
0
5 hours ago
Labels (1)
hnewell
Emerging Contributor

I seem to have a solution for this, at least for the time being, but want to document this possible bug/unusual behavior.

I wrote a script to update some domains of a hosted feature service on an Enterprise Portal, call it "Seed_Collection". My code (see attached example csv, names changed for privacy):

import arcgis
from arcgis.gis import GIS

feature_id = "<my feature ID>"

gis = arcgis.gis.GIS("Pro")

feature_conn = gis.content.get(feature_id)
pops_conn = feature_conn.layers[0]

personnel = pd.read_csv("seed_collection_personnel.csv")

domain = [{"name":p, "code":p} for p in personnel.Personnel]

update = {
    "fields":[
        {
            "name": "observer",
            "domain": {
                "name": "personnel",
                "type": "codedValue",
                "codedValues":domain
            }
        }
    ]
}

attempt = pops_conn.manager.update_definition(update)
if(attempt["success"]):
    print("Update successful!")
else:
    print("Update failed :(")

It worked fine for the first few runs, but a couple weeks later one of the domain updates failed with the following exception:

{'code': 500, 'message': "ERROR: Domain does not exist: '㛨㫀ȃ'", 'details': []}

I checked the and found that the domain name in the hosted feature service had changed from the original name it was published from ArcGIS Pro with, "personnel," to "Seed_Collection_personnel." So I changed the domain name to the new name in my update JSON, copied and pasted directly from the service properties. My code now looked like:

import arcgis
from arcgis.gis import GIS

feature_id = "<my feature ID>"

gis = arcgis.gis.GIS("Pro")

feature_conn = gis.content.get(feature_id)
pops_conn = feature_conn.layers[0]

personnel = pd.read_csv("seed_collection_personnel.csv")

domain = [{"name":p, "code":p} for p in personnel.Personnel]

update = {
    "fields":[
        {
            "name": "observer",
            "domain": {
                "name": "Seed_Collection_personnel",
                "type": "codedValue",
                "codedValues":domain
            }
        }
    ]
}

attempt = pops_conn.manager.update_definition(update)
if(attempt["success"]):
    print("Update successful!")
else:
    print("Update failed :(")

Same error, different string of characters:

{'code': 500, 'message': "ERROR: Domain does not exist: 'ϸ੫Ǩ'", 'details': []}

After lots of hair-pulling, I tried removing the domain name from the update JSON entirely, just to see what would happen. So my update JSON now looked like:

update = {
    "fields":[
        {
            "name": "observer",
            "domain": {
                # "name": "Seed_Collection_personnel",
                "type": "codedValue",
                "codedValues":domain
            }
        }
    ]
}

 

Predictably, this failed with the following exception:

{'code': 500, 'message': 'Database error has occurred.', 'details': []}

BUT, AFTER running the code with the domain_name removed, my previous code (second code chunk) ran successfully. I was able to resolve this problem for three different fields in three different layers, all originally published with the same "personnel" domain.

So, fixed for now 🎉. But very curious if anyone has any insight or solutions that don't require intentionally supplying an invalid JSON before supplying the correct one, in case it happens again. Thanks!

0 Kudos
0 Replies