confluencebuilder
confluencebuilder copied to clipboard
curl works, confluencebuilder not
If I test my connection with
curl -v https://confluence.mycompany.com/rest/api/space/MYSPACE -H "Authorization: Bearer averylongsecret"
I get a 200. All fine
Using this with confluencebuilder with debugging I get DEBUG:urllib3.connectionpool:https://confluence.mycompany.com:443 "GET /rest/api/space?spaceKey=MYSPACE&limit=1 HTTP/1.1" 200 None could not find the configured space.
What could be wrong?
@Kugeleis, just to sanity check, for the first request with a 200 response, do you also get expected API data back (i.e. a JSON response showing content like ID, name, etc.). Or do you get an empty 200 response? I assume the former, but the latter would be observed if there was an authentication issue.
I suspect that you are possibly using a PAT and not an API key. I want to make sure for this use case that you are using the configuration option confluence_publish_token (and not confluence_server_pass).
The request response you provided where it states HTTP/1.1 ... 200 None gives me an indication that the request was properly made to an instance, but the response return with no data. This is typically a sign of authentication issues.
With the curl command above I can access my space as wanted (e.g. with curl -v https://confluence.mycompany.com/rest/api/space/MYSPACE/content ...) I get the page list etc. Actually I'm using the atlassian confluence API python wrapper with this access method regularly.
I'm using PAT and I provide it to confluence_publish_token. I wrote a gist for you with the syntax which fails with 'could not find the configured space'. This gists code runs flawlessly with my space. I suspect urllib3 is doing something not equivalent to curl.
I just asked chatGPT to rewrite the curl-version with requests. This came out and it works, too.
Hmm... I do not see any immediate solution at this time. I am a bit curious why the connection is not working with this extension. This extension does use Requests, in a similar manner as your second sample. There isn't anything super complex to what this extension does.
Maybe, do you have any other auth-related options set (like confluence_server_user)? This may result in this extension stacking additional authentication options on a Requests session, which in turn may be causing this issues. Mind running a report capture?
python -m sphinxcontrib.confluencebuilder report
Also, do you mind indicating the error message generated when running this extension? I know you mentioned a specific debugging log message, but curious to know what specific message is generated for a generic use for this use case (helpful for tracking and future considerations).
The only other thing that I could ask for (if the above does not cover it or resolve anything) is possibly a more in-depth capture when running with the option confluence_publish_debug set (with the output sanitized with your discretion before attaching it here).
Here is the output of the report:
(system)
platform: Windows-10-10.0.22621-SP0
python: 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)]
sphinx: 7.2.6
docutils: 0.20.1
requests: 2.31.0
builder: 2.4.0
(configuration)
~default configuration~
(error loading configuration)
no documentation/missing configuration
My confluencebuilder config in sphinx conf.py is
confluence_publish = True
confluence_publish_debug = True
confluence_space_key = cf.space_key
confluence_parent_page = 1592657800
confluence_server_url = cf.domain
confluence_publish_token = cf.token
As you see the debug option is on. Finally here is what the command line looks like (complete):
(sphinx) PS C:\pathto\sphinx> sphinx-build -b confluence ./source/ ./build/ -E -a
Running Sphinx v7.2.6
<module 'confluence' from 'C:\\pathto\\python\\sphinx-test\\source\\confluence\\confluence.py'>
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): confluence.mycompany.com:443
DEBUG:urllib3.connectionpool:https://confluence.mycompany.infineon.com:443 "GET /rest/api/space?spaceKey=MYSPACE&limit=1 HTTP/1.1" 200 None
could not find the configured space
(notice to debugging user)
Either the space does not exist, or the user does not have permission to see
the space. Another space search will be performed to sanity check the
configuration to see if a similar space key exists, which can hint to a user
that the space key may be misconfigured. If the following search request
results in an access restriction, it is most likely that the authentication
options are not properly configured, even if the previous search request
reported a success (which can be permitted for anonymous users).
DEBUG:urllib3.connectionpool:https://confluence.mycompany.com:443 "GET /rest/api/search?cql=type%3Dspace+and+space.title~%22IGBT%22&limit=2 HTTP/1.1" 403 None
sphinxcontrib.confluencebuilder error:
---
Permission denied on Confluence (rest-call)
The configured user does not have permission to perform an action on the
Confluence instance. If the user should have access and this request is
using a personal access token, ensure the token is not expired/revoked.
(code: 403)
---
An observation: The debug message with DEBUG:urllib3.connectionpool:https://confluence.mycompany.com:443 "GET /rest/api/search?cql=type%3Dspace+and+space.title~%22IGBT%22&limit=2 HTTP/1.1" 403 None does something else than I tried with ´.../rest/api/space?spaceKey...´ which worked. I put
ps_execute_string = f'curl -H "Authorization: Bearer {token}" "{domain}/rest/api/search?cql=type%3Dspace+and+space.title~{space_key}&limit=2 HTTP/1.1"'
in my gist and this doesn't work.
Thanks for the report capture. Seems like the capture failed to process the configuration, but maybe that's expected in your setup if you have a complex Sphinx configuration. Unfortunately it doens't show the explicit configuration options loaded by the builder (but thanks for replicaing the ones you actually used, that helps) -- but more so, it does not have the explicit Confluence data center version you may be using. If you maybe could scroll to the bottom of any Confluence page to indicate the major+minor version (e.g. v8.8), I can spawn up a matching version to compare (if the issue is related to the specific Confluence version).
Interesting observation on the /rest/api/search... API call. It appears to me that Confluence has changed how the search capability may work. I'm not sure off hand if its now broken on my instance, newer Confluence versions or has additional requirements. Spawning an older Confluence instance shows expected results, where newer instances always appear to provide no space counts no matter what is set for the CQL (e.g. even just asking for any spaces). Although, the failure of this specific API is not a major issue for this extension. It was originally added in the past as a way to help search for similar spaces, since it was common at the time were people were complaining that they could not find a space, but turns out they adjusting the casing on the key, causing issues. The search was an attempt to help find similar spaces to suggest an alternative. It might be better if this extension just strips out all this extra logic, does a single space search and stops immediately if the exact match for a key is not found. I'll note to do this when looking at #858.
I was also performing some sanity checks with a local instance, comparing space search results using curl and comparing some of the results with this extension (and some additional prints). I haven't be able find anything yet, but I'll keep looking.
Various curl outputs
$ curl -s "INSTANCE_URL/confluence/rest/api/space/TEST" | json_pp -json_opt pretty,canonical
{
"data" : {
"allowedInReadOnlyMode" : true,
"authorized" : false,
"errors" : [],
"successful" : false,
"valid" : true
},
"message" : "No space found with key : TEST",
"reason" : "Not Found",
"statusCode" : 404
}
$ curl -s "INSTANCE_URL/confluence/rest/api/space?spaceKey=TEST&limit=1" | json_pp -json_opt pretty,canonical
{
"_links" : {
"base" : "INSTANCE_URL/confluence",
"context" : "/confluence",
"self" : "INSTANCE_URL/confluence/rest/api/space?spaceKey=TEST"
},
"limit" : 1,
"results" : [],
"size" : 0,
"start" : 0
}
$ curl -s "INSTANCE_URL/confluence/rest/api/space?spaceKey=TEST" | json_pp -json_opt pretty,canonical
{
"_links" : {
"base" : "INSTANCE_URL/confluence",
"context" : "/confluence",
"self" : "INSTANCE_URL/confluence/rest/api/space?spaceKey=TEST"
},
"limit" : 25,
"results" : [],
"size" : 0,
"start" : 0
}
$ curl -s -H "Authorization: Bearer OMITTED" "INSTANCE_URL/confluence/rest/api/space/TEST" | json_pp -json_opt pretty,canonical
{
"_expandable" : {
"description" : "",
"homepage" : "/rest/api/content/1277954",
"icon" : "",
"metadata" : "",
"retentionPolicy" : ""
},
"_links" : {
"base" : "INSTANCE_URL/confluence",
"collection" : "/rest/api/space",
"context" : "/confluence",
"self" : "INSTANCE_URL/confluence/rest/api/space/TEST",
"webui" : "/display/TEST"
},
"id" : 1310721,
"key" : "TEST",
"name" : "TEST",
"type" : "global"
}
$ curl -s -H "Authorization: Bearer OMITTED" "INSTANCE_URL/confluence/rest/api/space?spaceKey=TEST&limit=1" | json_pp -json_opt pretty,canonical
{
"_links" : {
"base" : "INSTANCE_URL/confluence",
"context" : "/confluence",
"self" : "INSTANCE_URL/confluence/rest/api/space?spaceKey=TEST"
},
"limit" : 1,
"results" : [
{
"_expandable" : {
"description" : "",
"homepage" : "/rest/api/content/1277954",
"icon" : "",
"metadata" : "",
"retentionPolicy" : ""
},
"_links" : {
"self" : "INSTANCE_URL/confluence/rest/api/space/TEST",
"webui" : "/display/TEST"
},
"id" : 1310721,
"key" : "TEST",
"name" : "TEST",
"type" : "global"
}
],
"size" : 1,
"start" : 0
}
$ curl -s -H "Authorization: Bearer OMITTED" "INSTANCE_URL/confluence/rest/api/space?spaceKey=TEST" | json_pp -json_opt pretty,canonical
{
"_links" : {
"base" : "INSTANCE_URL/confluence",
"context" : "/confluence",
"self" : "INSTANCE_URL/confluence/rest/api/space?spaceKey=TEST"
},
"limit" : 25,
"results" : [
{
"_expandable" : {
"description" : "",
"homepage" : "/rest/api/content/1277954",
"icon" : "",
"metadata" : "",
"retentionPolicy" : ""
},
"_links" : {
"self" : "INSTANCE_URL/confluence/rest/api/space/TEST",
"webui" : "/display/TEST"
},
"id" : 1310721,
"key" : "TEST",
"name" : "TEST",
"type" : "global"
}
],
"size" : 1,
"start" : 0
}
Extension prints on space searchs
extensions = [
'sphinxcontrib.confluencebuilder',
]
confluence_publish = True
confluence_server_url = 'INSTANCE_URL/confluence/'
confluence_publish_token = 'OMITTED'
confluence_space_key = 'TEST'
Running Sphinx v7.2.6
making output directory... done
...
rsp.status_code: 200
{
"results": [
{
"id": 1310721,
"key": "TEST",
"name": "TEST",
"type": "global",
"_links": {
"webui": "/display/TEST",
"self": "INSTANCE_URL/confluence/rest/api/space/TEST"
},
"_expandable": {
"metadata": "",
"icon": "",
"description": "",
"retentionPolicy": "",
"homepage": "/rest/api/content/1277954"
}
}
],
"start": 0,
"limit": 1,
"size": 1,
"_links": {
"self": "INSTANCE_URL/confluence/rest/api/space?spaceKey=TEST",
"base": "INSTANCE_URL/confluence",
"context": "/confluence"
}
}
...
Added an initial connection test action to this extension (which we can expand on when debugging this issue). If willing, mind installing this specific version:
pip install git+https://github.com/sphinx-contrib/confluencebuilder.git@introduce-connection-test
And then trying the following connection test from the Sphinx project (where conf.py resides):
python -m sphinxcontrib.confluencebuilder connection-test
I would be curious to see the raw results (although feel free to sanitize content such as the URL being used, if printed).
...but more so, it does not have the explicit Confluence data center version you may be using. If you maybe could scroll to the bottom of any Confluence page to indicate the major+minor version (e.g. v8.8), I can spawn up a matching version to compare (if the issue is related to the specific Confluence version).
sits at the end of each page
here is the output of python -m sphinxcontrib.confluencebuilder connection-test
Details
(sphinx) PS C:\code\sphinx-test\source> python -m sphinxcontrib.confluencebuilder connection-test
Fetching configuration information...
Running Sphinx v7.2.6
<module 'confluence' from 'C:\\code\\sphinx-test\\source\\confluence\\confluence.py'>
Sanity checks]
Checking that "confluence_server_url" is set... set.
Checking "confluence_server_url" value... good (HTTPS).
Confluence base URL: https://confluence.mycompany.com/
Confluence API endpoint: https://confluence.mycompany.com/rest/api
Checking that "confluence_space_key" is set... set.
Checking "confluence_space_key" value... looks good.
Checking proxy settings... no proxy configured.
Connection check]
Connecting to Confluence instance... DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): confluence.mycompany.com:443
DEBUG:urllib3.connectionpool:https://confluence.mycompany.com:443 "GET /rest/api/space?spaceKey=TEST&limit=1 HTTP/1.1" 200 None
could not find the configured space
(notice to debugging user)
Either ...
DEBUG:urllib3.connectionpool:https://confluence.mycompany.com:443 "GET /rest/api/search?cql=type%3Dspace+and+space.title~%22TEST%22&limit=2 HTTP/1.1" 403 None
failed to connect!
ERROR: Traceback (most recent call last):
File "C:\Users\me\.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\cmd\conntest.py", line 292, in conntest_main
publisher.connect()
File "C:\Users\me\.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\publisher.py", line 107, in connect
rsp = self.rest_client.get('search', search_fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 108, in _wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 150, in _wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 242, in get
self._handle_common_request(rsp)
File "C:\Users\me\.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 372, in _handle_common_request
raise ConfluencePermissionError('rest-call')
sphinxcontrib.confluencebuilder.exceptions.ConfluencePermissionError:
---
Permission denied on Confluence (rest-call)
The configured user does not have permission to perform an action on the
Confluence instance. If the user should have access and this request is
using a personal access token, ensure the token is not expired/revoked.
(code: 403)
---
@Kugeleis, thanks for the information.
I have made more changes to the introduce-connection-test branch, if you want to update and retry the connection test. This primarily includes:
- Using a simplified connection/space check at the start.
- Reworked the use of
confluence_publish_debugto dump full request/response URLs/headers/etc.
Maybe the new log changes will give better insight to the explicit headers being sent/received and provide some help.
Seems like you are using a custom variant of Confluence (which is fine)... just hard to know what specific version it was based on.
The only other thing that I could suggest you try (fishing here) is maybe changing the User-Agent field for requests (in the odd case where a server's front-end may not like this extension's value). For example, adding something like this:
confluence_publish_headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0',
}
update: we run on Confluence 7.19.17 (from the about page)
@Kugeleis, thanks for providing the explicit version of Confluence. Performed some testing today against that specific version of Confluence and I have not yet been able to produce the same connection issues you have been experiencing.
If you do not mind trying, I have made additional changes to the connection test, which you can upgrade using:
pip install -U git+https://github.com/sphinx-contrib/confluencebuilder.git@introduce-connection-test
And retrying the following command from your documentation's working directory:
python -m sphinxcontrib.confluencebuilder connection-test
Any information you can share from that run would be appreciated.
After a connection test run, another thing you can try is re-running the report request or documentation run using the "all" publish debug option that has been recently added. This should give you a raw inspection of the request made:
confluence_publish_debug = 'all'
Again, any information you can share from that output (which would require some more mindful sanitizing) would be appreciated. You are also welcome to Email me any results directly, if that helps.
At this time, I'm not sure what else to try off hand. The Confluence instance/gateway being interacted with is denying your requests (403). Maybe the publish debug run can reveal response headers indicating why the server is denying these requests. There has to be a specific reason why this is happening for your use case; and you may need to interact with the system administrator(s) of your instance to ask why this may be happening (ideally, they can see in their Confluence instance's log, reverse proxy log, etc. and see the explicit reason).
Here is the output with confluence_publish_debug = 'all' in conf.py (which doesn't seem to change an of the output).
output from python -m sphinxcontrib.confluencebuilder connection-test
Fetching configuration information... Running Sphinx v7.2.6 <module 'confluence' from 'C:\Users\me\Programmieren\python\sphinx-test\source\confluence\confluence.py'>
Sanity checks] Checking that "confluence_server_url" is set... set. Checking "confluence_server_url" value... good (HTTPS). Confluence base URL: https://confluence.mycompany.com/ Confluence API endpoint: https://confluence.mycompany.com/rest/api Checking that "confluence_space_key" is set... set. Checking "confluence_space_key" value... looks good. Checking proxy settings... no proxy configured.
Connection check] Connecting to Confluence instance... DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): confluence.mycompany.com:443 DEBUG:urllib3.connectionpool:https://confluence.mycompany.com:443 "GET /rest/api/space?spaceKey=TEST&limit=1 HTTP/1.1" 200 None could not find the configured space
(notice to debugging user) ...
DEBUG:urllib3.connectionpool:https://confluence.mycompany.com:443 "GET /rest/api/search?cql=type%3Dspace+and+space.title~%22TEST%22&limit=2 HTTP/1.1" 403 None failed to connect! ERROR: Traceback (most recent call last): File "C:\Users\me.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\cmd\conntest.py", line 292, in conntest_main publisher.connect() File "C:\Users\me.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\publisher.py", line 107, in connect rsp = self.rest_client.get('search', search_fields) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 108, in _wrapper return func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 150, in _wrapper return func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 242, in get self._handle_common_request(rsp) File "C:\Users\me.virtualenvs\sphinx-test-n1Xk8596\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 372, in _handle_common_request raise ConfluencePermissionError('rest-call') sphinxcontrib.confluencebuilder.exceptions.ConfluencePermissionError:
Permission denied on Confluence (rest-call)
The configured user does not have permission to perform an action on the Confluence instance. If the user should have access and this request is using a personal access token, ensure the token is not expired/revoked.
(code: 403)
It looks to me that this recent test is using an older source, since I believe the logic that prints "notice to debugging user" was removed.
Here is the output with confluence_publish_debug = 'all' in conf.py (with a fresh venv).
output from python -m sphinxcontrib.confluencebuilder connection-test
Fetching configuration information... Running Sphinx v7.2.6 <module 'confluence' from 'C:\Users\me\Programmieren\python\sphinx-test\source\confluence\confluence.py'>
Network-related configurations] confluence_proxy: (not set) confluence_publish_disable_api_prefix: (not set) confluence_publish_headers: (not set) confluence_publish_token: (set) confluence_request_session_override: (not set) confluence_server_auth: (not set) confluence_server_cookies: (not set) confluence_server_pass: (not set) confluence_server_url: (set) confluence_server_user: (not set) confluence_space_key: (set)
Sanity checks] Checking that "confluence_server_url" is set... good. Checking "confluence_server_url" value... good (HTTPS). Confluence base URL: https://confluence.mycompany.com/ Confluence API endpoint: https://confluence.mycompany.com/rest/api Checking that "confluence_space_key" is set... set. Checking "confluence_space_key" value... looks good. Checking proxy settings... no proxy configured.
Connection check] Connecting to Confluence instance... (debug) Request] GET https://confluence.mycompany.com/rest/api/space/TEST User-Agent: Sphinx Confluence Builder Accept-Encoding: gzip, deflate Accept: / Connection: keep-alive X-Atlassian-Token: no-check Authorization: Bearer 'NDA3verylongstringYVm'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): confluence.mycompany.com:443 DEBUG:urllib3.connectionpool:https://confluence.mycompany.com:443 "GET /rest/api/space/TEST HTTP/1.1" 404 None (debug) Response] Code: 404 x-confluence-cluster-node: 123456703 x-confluence-cluster-node-name: confluence-production-1 set-cookie: JSESSIONID=AE9EF46E0554BE94DE2E35691F816E25; Path=/; Secure; HttpOnly, d013277e46556554677a8c9a2f41=128334343677753bc11f5ee8cbe5ca; path=/; HttpOnly; Secure; SameSite=None cache-control: no-store expires: Thu, 01 Jan 1970 00:00:00 GMT x-content-type-options: nosniff content-encoding: gzip vary: User-Agent content-type: application/json transfer-encoding: chunked date: Thu, 14 Mar 2024 13:00:10 GMT
failed!
ERROR: Traceback (most recent call last):
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\sphinxcontrib\confluencebuilder\publisher.py", line 71, in connect
rsp = self.rest_client.get(f'space/{self.space_key}')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 109, in _wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 151, in _wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\sphinxcontrib\confluencebuilder\rest.py", line 244, in get
raise ConfluenceBadApiError(rsp.status_code, errdata)
sphinxcontrib.confluencebuilder.exceptions.ConfluenceBadApiError:
Unsupported Confluence API call
An unsupported Confluence API call has been made. See the following details for more information:
REQ: GET RSP: 404 URL: https://confluence.mycompany.com/rest/api API: space/TEST DATA: { "statusCode": 404, "data": { "authorized": false, "valid": true, "allowedInReadOnlyMode": true, "errors": [], "successful": false }, "message": "No space found with key : TEST", "reason": "Not Found" }
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\sphinxcontrib\confluencebuilder\cmd\conntest.py", line 302, in conntest_main
publisher.connect()
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\sphinxcontrib\confluencebuilder\publisher.py", line 77, in connect
raise ConfluenceUnknownInstanceError(
sphinxcontrib.confluencebuilder.exceptions.ConfluenceUnknownInstanceError:
Unknown Confluence URL or invalid/restricted space detected
An issue has been detected when trying to communicate with the configured Confluence instance. Ensure the instance is running and inspect that the configured Confluence URL is valid:
https://confluence.mycompany.com/
If the instance is valid, ensure the configured space key and approriate authentication permissions are configured.
Space key: TEST
Username: (empty)
Password or API Token: (empty)
Personal Access Token (PAT):
Connection failure. Probing... Will attempt to probe multiple API endpoints. DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): confluence.mycompany.com:443 Traceback (most recent call last): File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request self._validate_conn(conn) File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\connectionpool.py", line 1099, in _validate_conn conn.connect() File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\connection.py", line 653, in connect sock_and_verified = _ssl_wrap_socket_and_match_hostname( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\connection.py", line 806, in ssl_wrap_socket_and_match_hostname ssl_sock = ssl_wrap_socket( ^^^^^^^^^^^^^^^^ File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\util\ssl.py", line 465, in ssl_wrap_socket ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\util\ssl.py", line 509, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 517, in wrap_socket return self.sslsocket_class._create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1108, in _create self.do_handshake() File "C:\Users\me\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1379, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\connectionpool.py", line 793, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request raise new_e urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\requests\adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\connectionpool.py", line 847, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\urllib3\util\retry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='confluence.mycompany.com', port=443): Max retries exceeded with url: /rest/api/space?spaceKey=TEST&limit=1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
sys.exit(main())
^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\sphinxcontrib\confluencebuilder_main
rv = conntest_main(parser)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\sphinxcontrib\confluencebuilder\cmd\conntest.py", line 350, in conntest_main
conntest_probe(app.config)
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\sphinxcontrib\confluencebuilder\cmd\conntest.py", line 420, in conntest_probe
rsp = requests.get(
^^^^^^^^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\requests\api.py", line 73, in get
return request("get", url, params=params, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\Programmieren\python\sphinx-test.venv\Lib\site-packages\requests\adapters.py", line 517, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='confluence.mycompany.com', port=443): Max retries exceeded with url: /rest/api/space?spaceKey=TEST&limit=1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)')))
Probing v1 (no-auth-no-headers)...
@Kugeleis, thanks for the detailed output.
Tried a couple more things and updated the connection test implementation again to help improve some scenarios.
Based on the provided output, there may be one thing that may be causing issues. In the example output, the initial request dump shows the following:
(debug) Request]
GET https://confluence.mycompany.com/rest/api/space/TEST
User-Agent: Sphinx Confluence Builder
Accept-Encoding: gzip, deflate
Accept: /
Connection: keep-alive
X-Atlassian-Token: no-check
Authorization: Bearer 'NDA3verylongstringYVm'
Specifically, the Authorization header has a bearer value that is wrapped in single quotes. However, testing in another setup using a PAT on a test instance, the "private" token value is not wrapped:
(debug) Request]
GET http://localhost:1990/confluence/rest/api/space/TEST
User-Agent: Sphinx Confluence Builder
Accept-Encoding: gzip, deflate
Accept: application/json; charset=utf-8
Connection: keep-alive
X-Atlassian-Token: no-check
Authorization: Bearer Nzk1MDk4NDM5ODAzOhdqxpxql02/xg5Jh8Kxwq/2J+MK
It could be that somewhere in the run scripts the value for the token confluence_publish_token is been wrapped with single quotes inside some double quotes; or maybe a CI script is passing in a token value set with a single-quote wrapped token (instead of just the token itself).
If you don't mind inspecting how the confluence_publish_token is set and seeing if you can produce a scenario where the bearer token is not single-quote wrapped, I would be curious to know the results. If it does work, I could then add additional configuration checks to help warn a user of such a state.
At this time, it is assumed that either the above suggestion may have helped, or an alternative approach has been made. Will close this bug. Feel free to comment to re-open if needed.