So when I am trying to add a new file to a field in a form I get this error.
The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution.
I noticed that this error shows when a request parameter in the ajax request has brackets [].
An example of the Request Parameter is this:
system_args[key]: value