ColorBy(rep,value=None) results in RuntimeError

Using colorBy(rep,value=None) in a python script results in the following error:

>>> Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/paraview/servermanager.py", line 3190, in GetAssociationFromString
    return ASSOCIATIONS[val]
KeyError: 'NONE'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/paraview/servermanager.py", line 3193, in GetAssociationFromString
    return _LEGACY_ASSOCIATIONS[val]
KeyError: 'NONE'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 59, in <module>
  File "<string>", line 53, in __streamlines
  File "/usr/lib/python3.9/site-packages/paraview/simple.py", line 581, in ColorBy
    rep.SetScalarColoring(None, servermanager.GetAssociationFromString(association))
  File "/usr/lib/python3.9/site-packages/paraview/servermanager.py", line 3195, in GetAssociationFromString
    raise RuntimeError ("invalid association string '%s'" % val)
RuntimeError: invalid association string 'NONE'
>>>

The following logic is executed.

In paraview/simple.py from line 580

if value == None:
    rep.SetScalarColoring(None, servermanager.GetAssociationFromString(association))

In paraview/servermanager.py from line 3185

def GetAssociationFromString(val):
    """Returns array association integer value from its string representation"""
    global ASSOCIATIONS, _LEGACY_ASSOCIATIONS
    val = str(val).upper()
    try:
        return ASSOCIATIONS[val]
    except KeyError:
        try:
            return _LEGACY_ASSOCIATIONS[val]
        except KeyError:
            raise RuntimeError ("invalid association string '%s'" % val)

None of the dictionaries (ASSOCIATIONS and _LEGACY_ASSOCIATIONS have a ‘NONE’ key.

ASSOCIATIONS = { 'POINTS' : 0, 'CELLS' : 1, 'FIELD' : 2, 'VERTICES' : 4, 'EDGES' : 5, 'ROWS' : 6}
_LEGACY_ASSOCIATIONS = { 'POINT_DATA' : 0, 'CELL_DATA' : 1 }

Which version of ParaView ?

paraview version 5.8.1

Appending 'NONE':-1 to the ASSOSCIATION dictionary suppresses the error, but it is not a solution.

It seems in some case the data does not have default association … To avoid error in your code, you can try to add

rep.ColorArrayName = ['POINTS', '']

before calling ColorBy() …

@utkarsh.ayachit any idea ?
This is reproducible (also in master) with the following

from paraview.simple import *
Sphere()
r = Show()
# r.ColorArrayName = ['POINTS', '']
ColorBy(r, value=None)

This script generates error, uncomment the line and no more error.