deepmodeling / deepmodeling/deepmodeling_sphinx

[Code scan] Avoid mutating the global sitemap while rendering the banner

Open Beginner friendly
#86 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CSS
Stars
2
Forks
6
PR merge metrics
No merged PRs in 30d

Description

This issue is a result of a Codex global code scan of deepmodeling/deepmodeling_sphinx at commit 156679fe55fc61e8ec3b1e9be8a45fde3567b9cb.

Problem

`render_banner()` writes the active CSS class directly into the module-level `sitemap`. The mutation persists across subsequent calls, so rendering one site as active and then rendering another can leave multiple navigation items marked active.

Code references:

https://github.com/deepmodeling/deepmodeling_sphinx/blob/156679fe55fc61e8ec3b1e9be8a45fde3567b9cb/deepmodeling_sphinx/config.py#L1-L33
https://github.com/deepmodeling/deepmodeling_sphinx/blob/156679fe55fc61e8ec3b1e9be8a45fde3567b9cb/deepmodeling_sphinx/inject.py#L16-L35

Reproduction

```py
from deepmodeling_sphinx.inject import render_banner
from deepmodeling_sphinx.config import sitemap

render_banner("Docs")
render_banner("Blog")
print([(item["title"], item.get("class")) for item in sitemap if item.get("class")])
```

The output includes both `Docs` and `Blog` with `active docs-active`.

Impact

Repeated in-process builds, tests, or custom integrations that render the banner with different `deepmodeling_current_site` values can leak active state between renders.

Suggested fix

Build a per-render copy of the sitemap and assign active state on that copy, or compute the class in the Jinja template without mutating shared module state.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read deepmodeling_sphinx/config.py and deepmodeling_sphinx/inject.py, then run the issue's two-call render_banner reproduction. Ensure active state is isolated to each render so rendering Docs followed by Blog leaves only Blog active, without mutating the module-level sitemap.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.