Skip to content

Bad interaction between needs.id_required = true and src-trace need object #23

@MrChocolateMoose

Description

@MrChocolateMoose

Hi guys,

I think I may have discovered a bug related to the src_trace need.

When I have the following option in my toml:

[needs]
id_required = true

I am unable to stamp out a src-trace need without receiving the error


      File "/home/[my_paths]/site-packages/sphinx_needs/api/need.py", line 148, in generate_need
        raise InvalidNeedException(
            "missing_id", "No ID defined, but 'needs_id_required' is set to True."
        )
    sphinx_needs.exceptions.InvalidNeedException: No ID defined, but 'needs_id_required' is set to True. [missing_id]

due to this line:

        # create the need for src-trace directive
        src_trace_need = add_need(
            app=self.env.app,  # The Sphinx application object
            state=self.state,  # The docutils state object
            docname=self.env.docname,  # The current document name
            lineno=self.lineno,  # The line number where the directive is used
            need_type="srctrace",  # The type of the need
            title=title,  # The title of the need
            **extra_options,
        )
        needs.extend(src_trace_need)

I initially tried to add an ID field to the src_trace object, but it doesn't seem like it is being passed along so it didn't help.

My current workaround is obviously not using this setting. It is working for me as expected once I do this.

Strangely enough, it is generating an ID for the source trace objects implicitly after creation (at least what I observe in my HTML page).

Some thoughts: I hypothesize I could use the schema validation/ontologies to check whether the user filled out an 'ID' to further work around this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions