addSecrets() overwrites existing database settings and never marks secrets as added
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start with base/settings/R/addSecrets.R, especially the checks at lines 19–21 and 36–44 described in the issue. Add a regression test for existing database settings and for the secrets.added guard, using a temporary ~/.pecan.xml as suggested. Done means existing values are preserved and the added flag prevents secrets from being applied again.
Written by the indexing model from the issue text.
Description
addSecrets() is meant to copy database sections from ~/.pecan.xml only when the settings don't already have them, but it overwrites them every time.
# ~/.pecan.xml has <database><bety><user>from_pecan_xml</user><host>localhost</host>...</bety></database>
s <- PEcAn.settings::as.Settings(list(database = list(bety = list(
user = "mine", password = "x", host = "db.example.org", dbname = "bety"))))
out <- PEcAn.settings::addSecrets(s)
out$database$bety$user #> "from_pecan_xml"
out$database$bety$host #> "localhost"
is.null(out$settings.info$secrets.added) #> TRUE
(develop at 9fa7807, PEcAn.settings 1.9.1.9000, macOS arm64, R 4.5.2)
The check looks for the section among the top-level names instead of under database:
settings[section] with section = "bety" is never a top-level entry, so the "Already have a section" branch never runs and settings$database$bety is replaced from ~/.pecan.xml. Separately, settings.info$secrets.added is checked at L19-21 but never set, so the "added already" guard never triggers either.
Suggested fix: check section %in% names(settings[[key]]), and set settings$settings.info$secrets.added <- TRUE before returning, plus a test that uses a temporary ~/.pecan.xml (e.g. via withr::local_envvar(HOME = ...)) for both cases.
I didn't find an existing issue. Happy to open a PR if this sounds right.
- Dominant language
- R
- Stars
- 246
- Forks
- 322
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 21
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PecanProject/pecan
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PecanProject/pecan#4236 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PecanProject/pecan#4234 · 2 comments ·
Maintainers usually reply within 1 day
-
write.config.SIPNET warns about multiple vegetation PFTs when there's only onePossibly taken @aarmens702-hub claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PecanProject/pecan#4225 · 8 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
download.SM_CDS: CDS rejects the request, then the retry loop never endsPossibly taken @S1DDHEY claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PecanProject/pecan#4219 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
PecanProject/pecan#4218 · 1 comment ·
Maintainers usually reply within 1 day
All issues in PecanProject/pecan
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Open-Systems-Pharmacology/OSPSuite.ParameterIdentification#377 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
hubverse-org/hubAdmin#187 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
-
CREATE_ANNOTATED_TABLES reports r-ggplot2 version as null (packageVersion typo)Possibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
nf-core/nanostring#195 ·
Maintainers usually reply within 1 day