I noticed something puzzling working with single line text attribute max length (which is 4000 chars).
If you specified the max length of the primary attribute 450 chars or less when creating a new entity, and then you want to increase it, CRM will throw you a System.IndexOutOfRangeException.
However this is not the case if you create the new entity with primary attribute max length more than 451, CRM will allow you to increase the max length up to 4000 chars.
I also notice this issue does not affect normal attribute.
Does anyone else have encountered the same issue? If so how do you resolve it? Please comment below.