Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazarr: error when there are no series #244

Open
RobReus opened this issue Nov 20, 2023 · 3 comments
Open

Bazarr: error when there are no series #244

RobReus opened this issue Nov 20, 2023 · 3 comments

Comments

@RobReus
Copy link

RobReus commented Nov 20, 2023

When bazarr contains no series, it will still try to fetch the episodes. This results in the episodes api endpoint returning a 404, and as a result, exportarr returns a 500 to prometheus when prometheus tries to scrape the metrics. I believe this is a bug, as it would be a perfectly acceptable scenario to have no series in bazarr at all.

The culprit is in this part:

params := client.QueryParams{"seriesid[]": ids}

When no series are returned, the collector should not attempt to fetch the episodes (as there is nothing to fetch).

This is the error returned by exportarr /metrics when there are no series:

< HTTP/1.1 500 Internal Server Error

An error has occurred while serving metrics:

error collecting metric Desc{fqName: "bazarr_collector_error", help: "Error while collecting metrics", constLabels: {url="http://bazarr:6767"}, variableLabels: {}}: Failed to execute HTTP Request(http://bazarr:6767/api/episodes): Get "http://bazarr:6767/api/episodes": Received Client Error Status Code: 404

And from the exportarr logs:

2023-11-20T12:12:47.147+0100	INFO	Sending HTTP request	{"url": "http://bazarr:6767/api/system/health"}
2023-11-20T12:12:47.150+0100	INFO	Sending HTTP request	{"url": "http://bazarr:6767/api/system/status"}
2023-11-20T12:13:02.137+0100	INFO	Sending HTTP request	{"url": "http://bazarr:6767/api/series"}
2023-11-20T12:13:02.141+0100	INFO	Sending HTTP request	{"url": "http://bazarr:6767/api/episodes"}
2023-11-20T12:13:02.142+0100	ERROR	Error getting episodes subtitles	{"collector": "bazarr", "error": "Failed to execute HTTP Request(http://bazarr:6767/api/episodes): Get \"http://bazarr:6767/api/episodes\": Received Client Error Status Code: 404"}

As soon as you add sonarr to bazarr and it synced the series, it starts to work without problems.

Let me know if any other details are required.

@RobReus RobReus changed the title Error when there are no series Bazarr: error when there are no series Nov 20, 2023
PrivatePuffin pushed a commit to truecharts/public that referenced this issue Dec 20, 2023
**Description**
This adds exportarr to the bazarr application as bazarr is supported by
exportarr. This allows the user to have prometheus scrape for bazarr
metrics.

**⚙️ Type of change**

- [X] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
Created a personal catalog which I added to TrueNAS. I then installed
this app sourced from this catalog to ensure the questions + answers,
and actual installation works.

**📃 Notes:**
Exportarr for bazarr does not work without having the API key to access
bazarr set. I have added this as a question to the metrics part (see
below screenshot). Is this an acceptable way of doing this, or should it
be done differently? Unfortunately bazarr does not support setting the
api key via environment variables, so enabling metrics for a new
deployment requires 2 deployments. The first one without metrics enabled
to bootstrap bazarr, and then a second one to enable metrics and set the
api key.


![2023-11-20_12-26](https://github.com/truecharts/charts/assets/20680059/b9455821-6dc5-4f9e-bc8f-16461bbb394d)

Also, due to a bug in exportarr
(onedr0p/exportarr#244), exportarr does not
work when there are no series added/sonarr is not configured. Should
this be mentioned anywhere to the users of this chart?

**✔️ Checklist:**

- [X] ⚖️ My code follows the style guidelines of this project
- [X] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [X] ⬆️ I increased versions for any altered app according to semantic
versioning

**➕ App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._

---------

Signed-off-by: Kjeld Schouten <[email protected]>
Co-authored-by: Stavros Kois <[email protected]>
Co-authored-by: Kjeld Schouten <[email protected]>
@phyzical
Copy link
Contributor

while minor, easily avoided. will look at adding in a check at some point after #238 is merged

@phyzical
Copy link
Contributor

i adjusted the tests to take a bunch of empty json payloads, kept a series list so it would try for episodes and it didnt throw any errors. i don't think this is a reproducible as it seems.

Given how short the window for this to be an issue is id argue we just close (unless theres more info for reproduce?)

@rtrox
Copy link
Collaborator

rtrox commented Mar 5, 2024

There's really two situations that would lead to this state:

  1. As was reported, exportarr turning up while there are no series added to bazarr.
  2. The Series call fails for some other reason.

In the latter case, a 5XX response is the expected handling in prometheus, as this indicates to prometheus that the scrape failed (A 5XX actually flops the up metrics to 0). For the former case, we can just return if the response to the seriesId call is empty.

rtrox added a commit that referenced this issue Mar 5, 2024
@rtrox rtrox closed this as completed Aug 9, 2024
@rtrox rtrox reopened this Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants