crate-docs-theme icon indicating copy to clipboard operation
crate-docs-theme copied to clipboard

[RTD] Backward-compatibility code trips documentation builds on downstream projects

Open amotl opened this issue 1 year ago • 8 comments

About

Remove RTD backward-compatibility layer/module/code sphinx-build-compatibility again.

  • https://about.readthedocs.com/blog/2024/07/addons-by-default/

Why? It only needed to be enabled the other day, because we did not want to go down into yet another rabbit hole at that time.

Problem

The recently added RTD backward-compatibility code in src/crate/theme/vendor/rtd_compat/extension.py::manipulate_config is highly problematic when it comes to TimeoutErrors, as it emits warnings then, which trip the build, because they are treated as errors in our setting.

https://github.com/crate/crate-docs-theme/blob/064424148a1f064b007e96a50976f0fd772dbaba/src/crate/theme/vendor/rtd_compat/extension.py#L14-L131

References

WARNING: An error ocurred when hitting API to fetch active versions. Defaulting to an empty list.
WARNING: An error ocurred when generating the list of downloads. Defaulting to an empty list.
build finished with problems, 2 warnings.
  • https://readthedocs.org/projects/crate/builds/26356993/

amotl avatar Nov 21 '24 20:11 amotl

@amotl is that related to the issue that you were discussing on Slack with @BaurzhanSakhariev?

msbt avatar Nov 28 '24 12:11 msbt

I don't think it is related to this specific issue. While it might be related to general refurbishments and modernizations at RTD, the other thing is related to networking and connectivity issues, and this one is related to Sphinx, so effectively, totally different domains.

amotl avatar Nov 28 '24 13:11 amotl

An error ocurred when hitting API to fetch active versions.

Ah, right, both are about rejected requests, possibly by rate limiting machineries. So, well, yeah, in this case both issues are probably connected.

amotl avatar Nov 28 '24 13:11 amotl

Maybe we need to tell them about the IP address of our Jenkins server?

amotl avatar Nov 28 '24 13:11 amotl

Maybe we need to tell them about the IP address of our Jenkins server?

Hm, not necessarily. In this case, RTD is tripping itself: https://readthedocs.org/projects/crate/builds/26356993/

amotl avatar Nov 28 '24 13:11 amotl

I've now also observed it happening on my workstation, when working on cratedb-guide in sandbox mode.

Running Sphinx v7.1.2

Running "manipulate_config" from Read the Docs "sphinx_build_compatibility" extension. Consider removing it from your requirements and migrating your documentation accordingly. This extension is useful only as a transition but it will not be maintained.

Warning, treated as error:
An error ocurred when hitting API to fetch active versions. Defaulting to an empty list.
Command exited with exit code: 2

amotl avatar Dec 04 '24 23:12 amotl

Gentle ping. Also here, we need to put some attention to it.

/cc @msbt

amotl avatar Feb 27 '25 18:02 amotl

Ah this might explain why we currently don't have the old-version-banner

WARNING: An error ocurred when hitting API to fetch active versions. Defaulting to an empty list.

How should we go about this?

msbt avatar Mar 03 '25 09:03 msbt

It happens again.

  • https://github.com/crate/crate-pdo/actions/runs/14279551151/job/40027377425
  • https://github.com/crate/crate-python/actions/runs/14279558610/job/40027394491
  • https://github.com/crate/sqlalchemy-cratedb/actions/runs/14279529545/job/40027327340
Running "manipulate_config" from Read the Docs "sphinx_build_compatibility" extension. Consider removing it from your requirements and migrating your documentation accordingly. This extension is useful only as a transition but it will not be maintained.
WARNING: An error ocurred when hitting API to fetch project language. Defaulting to 'en'.
Traceback (most recent call last):
  File "/home/runner/work/crate-python/crate-python/docs/.crate-docs/.venv/lib/python3.12/site-packages/requests/models.py", line 974, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.9/x64/lib/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.9/x64/lib/python3.12/json/decoder.py", line 338, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.9/x64/lib/python3.12/json/decoder.py", line 356, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@msbt: I think we should finally tackle removing this compatibility extension.

amotl avatar Apr 05 '25 08:04 amotl

I've also reported this to upstream authors.

  • https://github.com/readthedocs/sphinx-build-compatibility/issues/3

amotl avatar Apr 05 '25 12:04 amotl

@amotl how would we go about it? Start fresh and add our things one by one or try to untangle it from the current state?

msbt avatar Apr 07 '25 07:04 msbt

I think we'd remove the compatibility layer, check what breaks, and fix forward as usual.

amotl avatar Apr 07 '25 13:04 amotl

Sounds good to me!

msbt avatar Apr 07 '25 13:04 msbt

  • I've staged a patch per GH-595. It will still need ~~more~~ the actual dissecting work.

amotl avatar Apr 07 '25 14:04 amotl

This would be the most prominent and most effective spot to remove from the compatibility layer, where it currently needs to ask the RTD API for help, while that hasn't been needed before:

  • https://github.com/crate/crate-docs-theme/pull/595#discussion_r2031411974

Maybe let's start there, because this is the actual pain point? The other context or environment variable adjustments coming from the compatibility layer, how ever they are interwingulated, are certainly weird from a maintenance standpoint, but do not cause actual pains right now.

It will still need ~~more~~ the actual dissecting work.

I've dissected the spot where requests are made to the RTD API in more detail now. See comments referenced below.

  • https://github.com/crate/crate-docs-theme/pull/595#pullrequestreview-2747135403

amotl avatar Apr 07 '25 14:04 amotl

  • GH-596 might be a tailored patch that will add immediate relief without much ado, and without needing to do the full thing.

amotl avatar Apr 07 '25 15:04 amotl

We hope the syndicate builds no longer trip on CI runs. At least it didn't happen last night. Closing this until further notice.

amotl avatar Apr 08 '25 18:04 amotl

The problem started happening again more frequently. It breaks linkchecker jobs on CI.

Running "manipulate_config" from Read the Docs "sphinx_build_compatibility" extension. Consider removing it from your requirements and migrating your documentation accordingly. This extension is useful only as a transition but it will not be maintained.
WARNING: An error occurred when hitting API to fetch active versions. Defaulting to an empty list.
Traceback (most recent call last):
  File "/home/runner/work/cratedb-guide/cratedb-guide/docs/.crate-docs/.venv/lib/python3.11/site-packages/requests/models.py", line 976, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

-- https://github.com/crate/cratedb-guide/actions/runs/16964399840/job/48084575017?pr=250#step:4:421

amotl avatar Aug 14 '25 11:08 amotl

We completed the "ignore those errors" mitigation we intended to add the other day, but failed on selecting the right logging level. Now, it does its job right.

  • GH-622

Of course, this doesn't mean the story is complete. While we may close this ticket, because the code no longer trips the build, it still needs to be removed to accompany the most recent upgrade/transition on RTDs end.

  • GH-623

amotl avatar Aug 24 '25 01:08 amotl

Problems are ignored for now, which resolves this.

amotl avatar Sep 18 '25 18:09 amotl