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

Setting the Confluence space doesn't work #11

Closed
jloeser opened this issue Aug 23, 2023 · 3 comments
Closed

Setting the Confluence space doesn't work #11

jloeser opened this issue Aug 23, 2023 · 3 comments

Comments

@jloeser
Copy link
Contributor

jloeser commented Aug 23, 2023

According to the docs you can change the space key on per-document basis:

<!-- confluence-space-key: DAP -->

This overrides the default space set via command-line arguments or environment variables.

This doesn't seem to work for me (someother is another valid space key) :

$ head testing.md -n2
<!-- confluence-page-id: 367198209 -->
<!-- confluence-space-key: ~62dfb0d2b6b0b70770d7d76c -->
$ python3 -m md2conf testing.md -s someother
2023-08-23 12:39:34,798 - INFO - _synchronize_page [87] - Synchronizing page: testing.md
2023-08-23 12:39:34,978 - INFO - update_page [363] - Updating page: 367198209
2023-08-23 12:39:35,086 - ERROR - <module> [89] - 400 Client Error: Bad Request for url: https://atix.atlassian.net/wiki/rest/api/content/367198209
2023-08-23 12:39:35,086 - ERROR - <module> [94] - {'statusCode': 400, 'data': {'authorized': True, 'valid': False, 'errors': [{'message': {'key': "You can't change an existing page's space.", 'args': []}}], 'successful': False}, 'message': 'com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not update Content of type : class com.atlassian.confluence.pages.Page with id 367198209'}

Another question is why is there a space key required via command-line arguments or environment variables at all? A space key tag in the document should be sufficient or not?

$ echo $CONFLUENCE_SPACE_KEY

$ head testing.md -n2
<!-- confluence-space-key: ~62dfb0d2b6b0b70770d7d76c -->
<!-- confluence-page-id: 367198209 -->
$ python3 -m md2conf testing.md
Traceback (most recent call last):
  File "/usr/lib64/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/jloeser/devel/envs/md2conf-env/lib/python3.10/site-packages/md2conf/__main__.py", line 82, in <module>
    with ConfluenceAPI(
  File "/home/jloeser/devel/envs/md2conf-env/lib/python3.10/site-packages/md2conf/api.py", line 117, in __init__
    raise ConfluenceError("Confluence space key not specified")
md2conf.api.ConfluenceError: Confluence space key not specified

Tested version of md2conf is revision 6627f42.

@hunyadi
Copy link
Owner

hunyadi commented Aug 23, 2023

I suppose the problem is that your Confluence space name contains a ~ character, and the regular expression for the confluence-space-key tag value is currently defined as (\w+), in which \w is typically equivalent to [a-zA-Z_0-9]. We could update the regular expression to be more permissive in the characters it accepts.

@hunyadi
Copy link
Owner

hunyadi commented Aug 23, 2023

The regular expression has been changed from (\w+) to (\S+) to capture ~ and other non-whitespace characters in the Confluence space name.

@hunyadi hunyadi closed this as completed Aug 23, 2023
@jloeser
Copy link
Contributor Author

jloeser commented Aug 29, 2023

The regular expression has been changed from (\w+) to (\S+) to capture ~ and other non-whitespace characters in the Confluence space name.

Thanks, the tilde prefix occurs on personal spaces in Confluence from what I see. With this fix at least the first issue is gone 👍

Still my question:

[...] why is there a space key required via command-line arguments or environment variables at all? A space key tag in the document should be sufficient or not?

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

2 participants