Repository navigation
feat: support GitHub organization-level global settings - #2504
Conversation
PR Summary by QodoSupport GitHub org-level global PR-Agent settings via pr-agent-settings repo
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
1. Bitbucket errors parsed as TOML
|
|
Code review by qodo was updated up to the latest commit 0a753ee |
Load a shared .pr_agent.toml from an <org>/pr-agent-settings repository (gated behind use_global_settings_file) and merge it beneath the repo's local settings so organizations can centralize defaults. get_repo_settings now returns an ordered (scope, content) list, and apply_repo_settings merges global -> local. Configuration errors from the global file report the source without echoing its contents into the PR.
…ution apply_repo_settings loaded global+local settings in a single Dynaconf call, so a parse/apply error in any file failed all of them and reported the error against the last source (mis-labeling e.g. a global-file error as 'local' and breaking global redaction). Apply each source independently and in order via _apply_repo_settings_file(); a failing source is reported against its own scope and no longer prevents the other valid sources from taking effect.
0a753ee to
2fc3ff7
Compare
|
Code review by qodo was updated up to the latest commit 2fc3ff7 |
… test fakes) - handle_configurations_errors: name the persistent comment/check run per scope (config-errors-<scope>) so multiple settings errors don't overwrite each other in GitHub check-run mode - _get_global_repo_settings: treat a missing/inaccessible <owner>/pr-agent-settings (GithubException 403/404) as an expected fallback logged at debug, not warning - test fakes: FakeRepo.get_contents accepts ref= and raises GithubException(404) like PyGithub, so tests don't break when PR_AGENT_CONFIG_BRANCH is set
|
Code review by qodo was updated up to the latest commit 8c8b3d1 |
… them The shared custom_merge_loader runs with silent=True, so malformed TOML and forbidden-directive SecurityErrors were logged and swallowed — meaning the new per-scope error reporting never fired for the most common bad-config cases. _apply_repo_settings_file now parses and security-validates the file explicitly first, so invalid global/local .pr_agent.toml raises and is reported against the correct scope (global redacted). Removes two xfail markers that documented this gap and were verifying the now-fixed behavior.
|
Code review by qodo was updated up to the latest commit 590bc32 |
…, decode) - _get_global_repo_settings: guard providers built via __new__ (no repo/client) so global-settings loading can't raise AttributeError and abort settings - get_repo_settings: treat a missing local .pr_agent.toml (404) as an expected condition logged at debug, not a warning (avoids high-volume log noise) - handle_configurations_errors: decode settings bytes with errors=replace so non-UTF-8 content can't crash the configuration-error comment
|
Code review by qodo was updated up to the latest commit 980e620 |
_apply_repo_settings_file parses the file with tomllib before Dynaconf runs, which bypassed the loader's MAX_TOML_SIZE_IN_BYTES guard — an oversized .pr_agent.toml could be fully parsed in-process (OOM/CPU) before being skipped. Promote the cap to a module-level constant in custom_merge_loader and check the file size first.
|
Code review by qodo was updated up to the latest commit 6b0662e |
- test_get_repo_settings_missing_local_file_logged_quietly: save/restore CONFIG.CONFIG_BRANCH so it doesn't leak global config and make the suite flaky - apply_repo_settings cleanup: include the exception reason in the error log message (loguru does not render an exception passed as an extra positional arg)
|
Code review by qodo was updated up to the latest commit cf0b15c |
The org-level global settings feature (<org>/pr-agent-settings) is implemented only for GitHub in this project; the section previously claimed GitLab/Bitbucket cloud support it does not have. Also clarify the file is read from the settings repo's default branch and merged beneath the repo-local config.
|
Code review by qodo was updated up to the latest commit 9b4bf65 |
Extend <org>/pr-agent-settings global configuration beyond GitHub: - GitLab (cloud): read <top-level-group>/pr-agent-settings (GitLab.com only) - Bitbucket (cloud): read <workspace>/pr-agent-settings Add a shared in-process TTL cache (get_cached_global_settings) so long-running webhook/app deployments don't re-fetch the global settings (and repeated 403/404 fallbacks) on every event — addressing the uncached-fetch concern. CLI/CI runs are short-lived and fetch once per invocation. Docs updated to reflect platform support and the in-process caching scope.
|
Code review by qodo was updated up to the latest commit 7392622 |
…s cache value size - bitbucket get_repo_settings: only treat a 200 response as a found local .pr_agent.toml; a 401/403/500 body must not be parsed as TOML (or echoed into a config-error comment) - get_cached_global_settings: skip caching oversized values (>1MB) so the process-wide cache can't retain large blobs (bounded independently of the 100MB apply-time cap)
|
Code review by qodo was updated up to the latest commit 9d1c02f |
…ings - gitlab: match the host exactly (urlparse hostname == 'gitlab.com') instead of a substring check, so self-hosted instances like 'mygitlab.com' don't load group settings - handle_configurations_errors: only decode settings content when it will be shown (non-global scope); global content is redacted, so skip the decode
|
Code review by qodo was updated up to the latest commit a723117 |
_apply_repo_settings_file passed the temporary file path to validate_file_security, whose SecurityError message is surfaced in the PR configuration-error comment — leaking an internal /tmp path to PR users on forbidden directives. Pass a generic '.pr_agent.toml' name instead so the error identifies the file without the server path.
|
Code review by qodo was updated up to the latest commit 5fcc685 |
…h errors, verify temp write - get_cached_global_settings + providers: fetch functions return "" only for expected not-found (404/403); transient/unexpected errors raise and are NOT cached, so a temporary outage no longer disables global settings for the full TTL - github get_repo_settings: only fall back to the default branch on a 404 config-branch error; other errors propagate instead of silently applying unintended settings - apply_repo_settings: write the temp settings file via os.fdopen so a partial os.write can't silently truncate it
|
Code review by qodo was updated up to the latest commit bb6cd81 |
…-settings outcome Align Bitbucket with GitHub: a 403 to the pr-agent-settings repo/file is a stable 'no access' condition, not a transient error, so return "" (cached) instead of raising and re-fetching on every event. Other statuses still raise (not cached).
|
Code review by qodo was updated up to the latest commit c13ad59 |
…se); neutral global error text - _apply_repo_settings_file: apply the dict already parsed by tomllib instead of re-reading the file through a second Dynaconf/custom_merge_loader pass — avoids double file I/O and TOML parsing per scope (and drops the phantom LOAD_DOTENV section). Section merge/host-key behavior is preserved (case-insensitive lookup; list/dict values replace) - handle_configurations_errors: global settings are org/group/workspace-scoped across providers, so the error text now names the 'pr-agent-settings' repository instead of GitHub-specific 'organization'
|
Code review by qodo was updated up to the latest commit c808b61 |
What & why
Split out from #2387 to keep each change reviewable on its own.
Lets an organization centralize PR-Agent defaults in a shared
<org>/pr-agent-settingsrepository. When enabled, its.pr_agent.tomlis loaded and merged beneath each repo's local.pr_agent.toml(local overrides global).GithubProvider.get_repo_settings()now returns an ordered(scope, content)list;apply_repo_settings()mergesglobal -> local.use_global_settings_fileconfig flag.use_global_settings_filealready defaults totrueinconfiguration.toml. With this change merged, GitHub flows will make a best-effort extra API call to fetch<org>/pr-agent-settings(silently returns empty if the repo doesn't exist). Please confirm whether that default is desired, or whether this should ship defaulting tofalse.Test
tests/unittest/test_github_provider_settings.pyand additions totest_git_provider_utils.pycover global/local merge precedence and the redaction-on-error behavior.ruffclean.Original work by @avidspartan1 (commit authorship preserved).