### Apache Airflow version

2.1.3 (latest released)

### Operating System

Debian Buster

### Versions of Apache Airflow Providers

_No response_

### Deployment

Managed Services (Astronomer, Composer, MWAA etc.)

### Deployment details

Running `quay.io/astronomer/ap-airflow:2.1.3-buster` Docker image

### What happened

In the task attributes view of a BashOperator, the `template_ext` row doesn't show any value, while I would expect to see `('.sh', '.bash')`.

![image](https://user-images.githubusercontent.com/6249654/131467817-8620f68d-0f3d-491d-ad38-cbf5b91cdcb3.png)


### What you expected to happen

Expect to see correct `template_ext` value

### How to reproduce

Run a BashOperator and browse to Instance Details --> scroll down to `template_ext` row

### Anything else

Spent a little time trying to figure out what could be the reason, but haven't found the problem yet. Therefore created issue to track.

### Are you willing to submit PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

airflow/serialization/serialized_objects.py
cls, object_to_serialize: Union[BaseOperator, DAG], decorated_fields: Set
    ) -> Dict[str, Any]:
        """Serializes an object to json"""
        serialized_object: Dict[str, Any] = {}
        keys_to_serialize = object_to_serialize.get_serialized_fields()
        for key in keys_to_serialize:
            
            value = getattr(object_to_serialize, key, None)
            if cls._is_excluded(value, key, object_to_serialize):
                continue
            if key in decorated_fields:
                serialized_object[key] = cls._serialize(value)
            elif key == "timetable":
                serialized_object[key] = encode_timetable(value)
            else:
                value = cls._serialize(value)
                if isinstance(value, dict) and "__type" in value:
                    value = value["__var"]
                serialized_object[key] = value
        return serialized_object
    @classmethod
    def _serialize(cls, var: Any) -> Any: