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

Sphinx-Needs throws exception when "." is used in ID #1096

Closed
twodrops opened this issue Jan 29, 2024 · 2 comments · Fixed by #1101
Closed

Sphinx-Needs throws exception when "." is used in ID #1096

twodrops opened this issue Jan 29, 2024 · 2 comments · Fixed by #1101

Comments

@twodrops
Copy link
Collaborator

Sphinx-Needs throws a cryptic python error

Extension error (sphinx_needs.directives.need):
Handler <function process_need_nodes at 0x7fc668dc98a0> for event 'doctree-resolved' threw an exception (exception: too many values to unpack (expected 2))

if "." is used in an ID after configuring a regex as follows in conf.py

needs_id_regex = r'.*'

Although it is not a good idea to use "." in IDs, Sphinx-Needs should be robust with such a case.

Related Issue: #852

@danwos
Copy link
Member

danwos commented Jan 30, 2024

I agree, there is a missing check for handling need_parts.

Short reminder: . is used to reference a need_part inside a need, e.g. REQ_123.SECTION_X.
It is generally not allowed by Sphinx-Needs to use a . in an ID, as the ID gets split by ..

In your case the returned value for the need_part is None or "", which is not detected and handled correctly.

@Rubyfi
Copy link
Contributor

Rubyfi commented Feb 6, 2024

I have a similar issue that seems to stem from the same root cause.
It surfaces when an invalid link is provided, e.g.:
:derives: This derives...
Here's a stacktrace:

Traceback (most recent call last):
  File "...\sphinx\events.py", line 96, in emit
    results.append(listener.handler(self.app, *args))
  File "...\sphinx_needs\directives\need.py", line 403, in process_need_nodes
    post_process_needs_data(app)
  File "...\sphinx_needs\debug.py", line 65, in wrapper
    return func(*args, **kwargs)
  File "...\sphinx_needs\directives\need.py", line 379, in post_process_needs_data
    check_links(needs, needs_config)
  File "...\sphinx_needs\directives\need.py", line 448, in check_links
    need_id, need_part_id = link.split(".")
ValueError: too many values to unpack (expected 2)

The debugger shows that link='This derives...'.

danwos pushed a commit that referenced this issue Feb 12, 2024
Ensure the splitting of a need ID, on a `.` into `main.part` IDs, cannot
except (and remove duplication of the logic)

closes #1096
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

Successfully merging a pull request may close this issue.

3 participants