dabla commented on PR #35591:
URL: https://github.com/apache/airflow/pull/35591#issuecomment-2266645114

   > @dabla - for this one we have to make sure that the tests are "compatible" 
with older versions of Airflow - because that is how we are testing 
compatibility of providers with older versions of Airflow - we run the tests 
after installing old airflow versions. So some assumptions that work in `main` 
version of airflow might not work. Which means that sometimes you might need to 
add `tests/test_utils/compat.py` code to make such test be compatible with 
Airflow 2.7+ and import / run some common test code from there.
   > 
   > Details here: 
https://github.com/apache/airflow/blob/main/contributing-docs/testing/unit_tests.rst#compatibility-provider-unit-tests-against-older-airflow-releases
   
   Hello @potiuk , I know this is a tuff one on different levels.  Will check 
the compat part and come back to it.  For the backward compat with 2.7 I did 
the following in the Hook itself, maybe that's the thing that needs to be 
changed then:
   
   ```
   class ConnectionWithExtra(Connection):
       """
       Patched Connection class added for backward compatibility.
       Implements the `get_extra_dejson` method which was added in the 
Connection class in Airflow 2.10.0.
       This patched class must be removed once the http provider depends on 
Airflow 2.10.0 or higher.
       """
   
       def __init__(
           self,
           conn_id: str | None = None,
           conn_type: str | None = None,
           description: str | None = None,
           host: str | None = None,
           login: str | None = None,
           password: str | None = None,
           schema: str | None = None,
           port: int | None = None,
           extra: str | dict | None = None,
           uri: str | None = None,
       ):
           super().__init__(conn_id, conn_type, description, host, login, 
password, schema, port, extra, uri)
   
       def get_extra_dejson(self, nested: bool = False) -> dict:
           """
           Deserialize extra property to JSON.
           :param nested: Determines whether nested structures are also 
deserialized into JSON (default False).
           """
           extra = {}
   
           if self.extra:
               try:
                   if nested:
                       for key, value in json.loads(self.extra).items():
                           extra[key] = value
                           if isinstance(value, str):
                               with suppress(JSONDecodeError):
                                   extra[key] = json.loads(value)
                   else:
                       extra = json.loads(self.extra)
               except JSONDecodeError:
                   self.log.exception("Failed parsing the json for conn_id %s", 
self.conn_id)
   
               # Mask sensitive keys from this list
               mask_secret(extra)
   
           return extra
   ```
   I've also added a [test 
](https://github.com/apache/airflow/pull/35591/files#diff-c1fea0f5710c4fc5d94cf03861e8fcec65925ddca9de2aef434157c0bd19dfaaR681)
 on it to check when it has to be removed once http provider depends on Airflow 
2.9.3 or higher.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to