Identify config report origin

After upgrading my own Foreman instance from 3.3 to 3.4 (and now 3.5, but it was present in 3.4) I realized there’s a regression: it no longer reports the origin for Puppet reports.

So digging into this, I found that this is how we identify a Puppet report:

In short: if there’s a log entry with a source that matches Puppet, it’s Puppet. However, in 3.4 I made this change:

This means that for uneventful reports there is no longer any log message, just metrics that Puppet ran (which is needed to ensure that the host isn’t out of sync). Now the problem becomes: how do we identify this case. Looking at the API, there’s no field for the source/origin:

https://apidocs.theforeman.org/foreman/3.4/apidoc/v2/config_reports/create.html

We can look at how foreman_ansible does it:

It looks like it invents the field reporter in the API, which is accepted since we don’t have strict validation, but would probably break if we turn it on.

So my question is: how do we solve this? Do we enhance the API and add a formal origin or format field to it rather than relying on autodetection?

Reported this as Bug #35833: Puppet configuration reports without entries do not get an origin - Foreman

And I opened a proposal to expose the origin directly.
https://github.com/theforeman/foreman/pull/9536