keep icon indicating copy to clipboard operation
keep copied to clipboard

SignalFx _get_alerts returns [] when every incident fails to format — VictoriaMetrics raises

Open siliroid opened this issue 3 months ago • 1 comments

Two providers, same method name, opposite answers to the same failure.

SignalFx — signalfx_provider.py:147-164:

    def _get_alerts(self):
        response = requests.get(f"{self.api_url}/v2/incident", headers=headers)
        response.raise_for_status()
        incidents = response.json()
        alerts = []
        for incident in incidents:
            try:
                alerts.append(self._format_alert_get_alert(incident))
            except Exception as e:
                self.logger.error(f"Failed to format SignalFx alert: {e}")
                pass
        return alerts

VictoriaMetrics — victoriametrics_provider.py:444-471:

        try:
            ...
            for alert in response["data"]["alerts"]:
                alerts.append(AlertDto(...))
            return alerts
        except Exception as e:
            self.logger.exception("Failed to get alerts")
            raise e

If every incident fails to format, SignalFx _get_alerts returns []. In an alerting product [] is not a neutral value — it is the answer "nothing is wrong", which is the one result nobody double-checks. A total formatting failure and a genuinely quiet SignalFx return the same thing.

The detection already exists: logger.error, per item, with the exception. It goes to a log. The return value carries none of it, and the return value is what the pipeline acts on.

Scope — what I am not claiming

The HTTP layer is handled correctly; raise_for_status() at :152 means a transport failure does raise. The gap is one layer in, at the per-item boundary.

And partial returns are fine — with 9 of 10 formatting, returning 9 is right. The claim is only about the 0-of-N boundary, where "all of them failed" and "there were none" become identical.

I also checked whether this was a pattern across providers rather than one file. It is not — VictoriaMetrics raises, and ServiceNow has no _get_alerts at all (only _query at :279). One provider out of step with its sibling, not a class.

Suggested change

Either match VictoriaMetrics and let it raise, or keep partial results and refuse to return an empty list when every item errored:

        failed = 0
        for incident in incidents:
            try:
                alerts.append(self._format_alert_get_alert(incident))
            except Exception as e:
                failed += 1
                self.logger.error(f"Failed to format SignalFx alert: {e}")
        if incidents and not alerts:
            raise Exception(f"all {failed} SignalFx incidents failed to format")
        return alerts

No change on the happy path or on partial failure. The one case that currently reports all-clear stops doing so.

Happy to open a PR if the direction is welcome.


I do reliability work on one specific class — a check that did not happen and a check that passed producing the same artifact. Found this while surveying; it stands whatever you decide about me.

If you want the same pass over the rest of the provider layer, that is $1,500 for a day — you, me, your codebase, on a call, every patch and repro yours the same day. Terms at https://unreached.dev/audit.html, where I publish my own false-positive rates and the findings I killed before filing.

siliroid avatar Aug 06 '26 01:08 siliroid

Hi @siliroid! I'm Dosu and I'm helping the Keep team.

Good catch. The analysis holds up — I verified the code and the pattern split is real.

SignalFx's _get_alerts does indeed silently return [] when every incident fails formatting [1], while VictoriaMetrics re-raises on failure [2]. There's no base class contract enforcing either strategy — BaseProvider._get_alerts is just a stub that raises NotImplementedError [3], so each provider picks its own approach.

It's worth noting this isn't strictly a one-provider issue though. Datadog follows the same silent-skip pattern as SignalFx — per-item try-except that logs and continues, same empty-list-on-total-failure behavior [4]. Meanwhile Dynatrace, Zabbix, and Prometheus all use the all-or-nothing style like VictoriaMetrics [5] [6] [7].

Your suggested fix — keep partial results but refuse to return empty when every item errored — is a clean middle ground that doesn't change behavior on the happy path or partial failure. If a PR is opened, the same fix would apply to Datadog's _get_alerts as well.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about keep Share Dosu with your team

dosubot[bot] avatar Aug 06 '26 02:08 dosubot[bot]