home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.57k stars 30.35k forks source link

seventeentrack get_packages throws error when package has no valid timestamp #128273

Open rk1664 opened 2 days ago

rk1664 commented 2 days ago

The problem

Running seventeentrack get_packages in a template sensor or automation logs an error if a package does not have a valid timestamp, such as a "not found" package with no timestamp information. See log message below.

What version of Home Assistant Core has the issue?

core-2024.10.1

What was the last working version of Home Assistant Core?

core-2024.9.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

seventeentrack

Link to integration documentation on our website

https://www.home-assistant.io/integrations/seventeentrack

Diagnostics information

No response

Example YAML snippet

template:
  - trigger:
      - platform: time_pattern
        #hours: /1
        minutes: /2 # For testing
    action:
      - action: seventeentrack.get_packages
        metadata: {}
        data:
          config_entry_id: 1234567890abcd #change this
          package_state:
            - not_found
        response_variable: not_found
    sensor:
      - name: 17Track Packages
        unique_id: 17track_packages
        state: "{{ now().isoformat() }}"
#... Process not_found response variable...

Anything in the logs that might be useful for us?

Logger: homeassistant
Source: components/seventeentrack/services.py:92
First occurred: 11 October 2024 at 00:00:02 (45 occurrences)
Last logged: 20:00:02

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/template/coordinator.py", line 113, in _handle_triggered_with_script
    if script_result := await self._script.async_run(run_variables, script_context):
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1795, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 557, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/seventeentrack/services.py", line 92, in get_packages
    ATTR_TIMESTAMP: package.timestamp.isoformat(),
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'isoformat'

Additional information

Pretty sure this started with core-2024-10.0, presumably caused by this commit: https://github.com/home-assistant/core/pull/127052/commits

home-assistant[bot] commented 2 days ago

Hey there @shaiu, mind taking a look at this issue as it has been labeled with an integration (seventeentrack) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `seventeentrack` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign seventeentrack` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


seventeentrack documentation seventeentrack source (message by IssueLinks)