refactor(backend/integrations): clearer naming + docs for managed-cred sweep - #12908
Conversation
…d sweep Review feedback on #12883 surfaced a few pieces of managed-credential machinery where naming/docs didn't match behaviour. Tightening them now without touching logic: - ``_read_or_create_profile_key`` → ``_migrate_legacy_or_create_profile_key``. The old name implied "read from any source or create new", but the function only migrates the legacy ``ayrshare_profile_key`` side-channel — the check for an existing managed credential lives in the outer ``_provision_under_lock`` (via ``has_managed_credential``). The new name reflects that, and the docstring spells out why it doesn't need to re-check the managed cred. - Replaced every "startup sweep" reference with "credentials sweep". Nothing fires at app startup — the sweep runs when the frontend calls ``/credentials`` or ``/{provider}/credentials`` for the first time on a fresh pod. - Expanded ``ManagedCredentialProvider`` class docstring to name the two gates explicitly: ``auto_provision`` (does the provider take part in the sweep at all?) and ``is_available`` (are upstream env vars / secrets set?). ``is_available`` now has a docstring that spells out it's a config check, not a liveness check, and is only consulted when ``auto_provision=True``. - Updated ``ensure_managed_credentials`` docstring: defines what the "credentials sweep" is, when it fires, how the in-memory cache works, and how failures are handled. - Updated module docstring to mention both ``ensure_managed_credentials`` and ``ensure_managed_credential`` and drop the stale "non-blocking background task" wording (#12883 made the sweep bounded-await). No behavior change. Zero-diff in the logic paths — just names and documentation that matches what the code actually does.
WalkthroughThe PR updates documentation and comments across the managed credentials and Ayrshare provider modules to clarify the "credentials sweep" provisioning model and its two provisioning gates. An internal helper function is renamed to better reflect its "migrate legacy or create" behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 PR Overlap DetectionThis check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early. 🟢 Low Risk — File Overlap OnlyThese PRs touch the same files but different sections (click to expand)
Summary: 0 conflict(s), 0 medium risk, 1 low risk (out of 1 PRs with file overlap) Auto-generated on push. Ignores: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py (1)
81-81: Optional: rename test class to match the renamed helper.The PR renames
_read_or_create_profile_key→_migrate_legacy_or_create_profile_keyto better reflect intent. The enclosing test classTestReadOrCreateProfileKeyis now named after the old helper and works against the PR's naming-clarity goal. Consider renaming to e.g.TestMigrateLegacyOrCreateProfileKeyfor consistency.♻️ Proposed rename
-class TestReadOrCreateProfileKey: +class TestMigrateLegacyOrCreateProfileKey: """Legacy migration + fresh-profile paths.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py` at line 81, Rename the test class TestReadOrCreateProfileKey to match the renamed helper _migrate_legacy_or_create_profile_key (e.g., TestMigrateLegacyOrCreateProfileKey) so the test class name reflects the current helper name; update any references to TestReadOrCreateProfileKey within the test file to the new class name and ensure test discovery still runs against methods that exercise _migrate_legacy_or_create_profile_key.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py`:
- Line 81: Rename the test class TestReadOrCreateProfileKey to match the renamed
helper _migrate_legacy_or_create_profile_key (e.g.,
TestMigrateLegacyOrCreateProfileKey) so the test class name reflects the current
helper name; update any references to TestReadOrCreateProfileKey within the test
file to the new class name and ensure test discovery still runs against methods
that exercise _migrate_legacy_or_create_profile_key.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2f1cd2dd-9442-419b-ac32-0eb44a07941b
📒 Files selected for processing (4)
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: check API types
- GitHub Check: test (3.11)
- GitHub Check: type-check (3.11)
- GitHub Check: type-check (3.12)
- GitHub Check: type-check (3.13)
- GitHub Check: test (3.13)
- GitHub Check: test (3.12)
- GitHub Check: end-to-end tests
- GitHub Check: Analyze (typescript)
- GitHub Check: Check PR Status
- GitHub Check: Analyze (python)
🧰 Additional context used
📓 Path-based instructions (5)
autogpt_platform/backend/**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development
autogpt_platform/backend/**/*.py: Usepoetry run ...command for executing Python package dependencies
Use top-level imports only — avoid local/inner imports except for lazy imports of heavy optional dependencies likeopenpyxl
Use absolute imports withfrom backend.module import ...for cross-package imports; single-dot relative imports are acceptable for sibling modules within the same package; avoid double-dot relative imports
Do not use duck typing — avoidhasattr/getattr/isinstancefor type dispatch; use typed interfaces/unions/protocols instead
Use Pydantic models over dataclass/namedtuple/dict for structured data
Do not use linter suppressors — no# type: ignore,# noqa,# pyright: ignore; fix the type/code instead
Prefer list comprehensions over manual loop-and-append patterns
Use early return with guard clauses first to avoid deep nesting
Use%sfor deferred interpolation indebuglog statements for efficiency; use f-strings elsewhere for readability (e.g.,logger.debug("Processing %s items", count)vslogger.info(f"Processing {count} items"))
Sanitize error paths by usingos.path.basename()in error messages to avoid leaking directory structure
Be aware of TOCTOU (Time-Of-Check-Time-Of-Use) issues — avoid check-then-act patterns for file access and credit charging
Usetransaction=Truefor Redis pipelines to ensure atomicity on multi-step operations
Usemax(0, value)guards for computed values that should never be negative
Keep files under ~300 lines; if a file grows beyond this, split by responsibility (extract helpers, models, or a sub-module into a new file)
Keep functions under ~40 lines; extract named helpers when a function grows longer
...
Files:
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
autogpt_platform/backend/backend/api/features/**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Update routes in '/backend/backend/api/features/' and add/update Pydantic models in the same directory for API development
Files:
autogpt_platform/backend/backend/api/features/integrations/router.py
autogpt_platform/{backend,autogpt_libs}/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Format Python code with
poetry run format
Files:
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
autogpt_platform/backend/**/api/**/*.py
📄 CodeRabbit inference engine (autogpt_platform/backend/AGENTS.md)
autogpt_platform/backend/**/api/**/*.py: UseSecurity()instead ofDepends()for authentication dependencies to get proper OpenAPI security specification
Follow SSE (Server-Sent Events) protocol: usedata:lines for frontend-parsed events (must match Zod schema) and: commentlines for heartbeats/status
Files:
autogpt_platform/backend/backend/api/features/integrations/router.py
autogpt_platform/backend/**/*_test.py
📄 CodeRabbit inference engine (autogpt_platform/backend/AGENTS.md)
autogpt_platform/backend/**/*_test.py: Use pytest with snapshot testing for API responses
Colocate test files with source files using*_test.pynaming convention
Mock at boundaries — mock where the symbol is used, not where it's defined; after refactoring, update mock targets to match new module paths
UseAsyncMockfromunittest.mockfor async functions in tests
When writing tests, use Test-Driven Development (TDD): write failing tests marked with@pytest.mark.xfailbefore implementation, then remove the marker once the implementation is complete
When creating snapshots in tests, usepoetry run pytest path/to/test.py --snapshot-update; always review snapshot changes withgit diffbefore committing
Files:
autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
🧠 Learnings (16)
📓 Common learnings
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12213
File: autogpt_platform/frontend/src/app/api/openapi.json:10030-10037
Timestamp: 2026-03-01T07:59:02.311Z
Learning: Repo: Significant-Gravitas/AutoGPT PR: 12213 — For MCP manual token storage, backend model autogpt_platform/backend/backend/api/features/mcp/routes.py defines MCPStoreTokenRequest.token as Pydantic SecretStr with a min length constraint, which generates OpenAPI schema metadata (format: "password", writeOnly: true, minLength: 1) in autogpt_platform/frontend/src/app/api/openapi.json. Prefer SecretStr (with length constraints) for sensitive request fields so generated TS clients and docs treat them as secrets.
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12284
File: autogpt_platform/frontend/src/app/api/openapi.json:11897-11900
Timestamp: 2026-03-04T23:58:18.476Z
Learning: Repo: Significant-Gravitas/AutoGPT — PR `#12284`
Backend/frontend OpenAPI codegen convention: In backend/api/features/store/model.py, the StoreSubmission and StoreSubmissionAdminView models define submitted_at: datetime | None, changes_summary: str | None, and instructions: str | None with no default. This is intentional to produce “required but nullable” fields in OpenAPI (properties appear in required[] and use anyOf [type, null]). This matches Prisma’s submittedAt DateTime? and changesSummary String?. Do not flag this as a required/nullable mismatch.
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12536
File: autogpt_platform/frontend/src/app/api/openapi.json:5770-5790
Timestamp: 2026-03-24T21:25:15.983Z
Learning: Repo: Significant-Gravitas/AutoGPT — PR `#12536`
File: autogpt_platform/frontend/src/app/api/openapi.json
Learning: The OpenAPI spec file is auto-generated; per established convention, endpoints generally declare only 200/201, 401, and 422 responses. Do not suggest adding explicit 403/404 response entries for single operations unless planning a repo-wide spec update. Prefer clarifying such behaviors in endpoint descriptions/docstrings instead of altering response maps.
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12566
File: autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts:968-974
Timestamp: 2026-03-26T00:32:06.673Z
Learning: In Significant-Gravitas/AutoGPT, the admin-facing methods in `autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts` (e.g., `addUserCredits`, `getUsersHistory`, `getUserRateLimit`, `resetUserRateLimit`) intentionally follow the legacy `BackendAPI` pattern with manually defined types in `autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts`. Migrating these admin endpoints to the generated OpenAPI hooks (`@/app/api/__generated__/endpoints/`) is a planned separate effort covering all admin endpoints together, not done piecemeal per PR. Do not flag individual admin type additions in `types.ts` as blocking issues.
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12536
File: autogpt_platform/frontend/src/app/api/openapi.json:5732-5752
Timestamp: 2026-03-24T21:27:22.326Z
Learning: Repo: Significant-Gravitas/AutoGPT — Preference: Do not add explicit 403/404 entries to FastAPI route decorators for admin endpoints just to influence OpenAPI. Keep openapi.json autogenerated and use route docstrings to document admin-only (403) and not-found (404) behavior; rely on tests for enforcement. File context: autogpt_platform/backend/backend/api/features/admin/store_admin_routes.py. PR `#12536`.
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 11795
File: autogpt_platform/backend/backend/api/features/chat/tools/utils.py:92-111
Timestamp: 2026-01-19T07:20:23.494Z
Learning: In autogpt_platform/backend/backend/api/features/chat/tools/utils.py, the _serialize_missing_credential function uses next(iter(field_info.provider)) for provider selection. The PR author confirmed this non-deterministic provider selection is acceptable because the function returns both "type" (single, for backward compatibility) and "types" (full array), which achieves the primary goal of deterministic credential type presentation.
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/backend/backend/api/features/**/*.py : Update routes in '/backend/backend/api/features/' and add/update Pydantic models in the same directory for API development
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.py
📚 Learning: 2026-03-07T07:43:15.754Z
Learnt from: kcze
Repo: Significant-Gravitas/AutoGPT PR: 12328
File: autogpt_platform/frontend/src/app/api/openapi.json:1116-1118
Timestamp: 2026-03-07T07:43:15.754Z
Learning: In Significant-Gravitas/AutoGPT, v2 chat endpoints often declare HTTPBearerJWT at the router level while using Depends(auth.get_user_id) that returns None for unauthenticated users; effective behavior is optional auth. Keep this convention unless doing a repo-wide OpenAPI update; prefer clarifying descriptions over per-operation security changes.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.py
📚 Learning: 2026-03-24T21:27:22.326Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12536
File: autogpt_platform/frontend/src/app/api/openapi.json:5732-5752
Timestamp: 2026-03-24T21:27:22.326Z
Learning: Repo: Significant-Gravitas/AutoGPT — Preference: Do not add explicit 403/404 entries to FastAPI route decorators for admin endpoints just to influence OpenAPI. Keep openapi.json autogenerated and use route docstrings to document admin-only (403) and not-found (404) behavior; rely on tests for enforcement. File context: autogpt_platform/backend/backend/api/features/admin/store_admin_routes.py. PR `#12536`.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.py
📚 Learning: 2026-03-04T23:58:18.476Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12284
File: autogpt_platform/frontend/src/app/api/openapi.json:11897-11900
Timestamp: 2026-03-04T23:58:18.476Z
Learning: Repo: Significant-Gravitas/AutoGPT — PR `#12284`
Backend/frontend OpenAPI codegen convention: In backend/api/features/store/model.py, the StoreSubmission and StoreSubmissionAdminView models define submitted_at: datetime | None, changes_summary: str | None, and instructions: str | None with no default. This is intentional to produce “required but nullable” fields in OpenAPI (properties appear in required[] and use anyOf [type, null]). This matches Prisma’s submittedAt DateTime? and changesSummary String?. Do not flag this as a required/nullable mismatch.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.py
📚 Learning: 2026-02-26T17:02:22.448Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12211
File: .pre-commit-config.yaml:160-179
Timestamp: 2026-02-26T17:02:22.448Z
Learning: Keep the pre-commit hook pattern broad for autogpt_platform/backend to ensure OpenAPI schema changes are captured. Do not narrow to backend/api/ alone, since the generated schema depends on Pydantic models across multiple directories (backend/data/, backend/blocks/, backend/copilot/, backend/integrations/, backend/util/). Narrowing could miss schema changes and cause frontend type desynchronization.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
📚 Learning: 2026-03-05T15:42:08.207Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12297
File: .claude/skills/backend-check/SKILL.md:14-16
Timestamp: 2026-03-05T15:42:08.207Z
Learning: In Python files under autogpt_platform/backend (recursively), rely on poetry run format to perform formatting (Black + isort) and linting (ruff). Do not run poetry run lint as a separate step after poetry run format, since format already includes linting checks.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
📚 Learning: 2026-03-16T16:35:40.236Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12440
File: autogpt_platform/backend/backend/api/features/workflow_import.py:54-63
Timestamp: 2026-03-16T16:35:40.236Z
Learning: Avoid using the word 'competitor' in public-facing identifiers and text. Use neutral naming for API paths, model names, function names, and UI text. Examples: rename 'CompetitorFormat' to 'SourcePlatform', 'convert_competitor_workflow' to 'convert_workflow', '/competitor-workflow' to '/workflow'. Apply this guideline to files under autogpt_platform/backend and autogpt_platform/frontend.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
📚 Learning: 2026-03-31T15:37:38.626Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12623
File: autogpt_platform/backend/backend/copilot/tools/agent_generator/fixer.py:37-47
Timestamp: 2026-03-31T15:37:38.626Z
Learning: When validating/constructing Anthropic API model IDs in Significant-Gravitas/AutoGPT, allow the hyphen-separated Claude Opus 4.6 model ID `claude-opus-4-6` (it corresponds to `LlmModel.CLAUDE_4_6_OPUS` in `autogpt_platform/backend/backend/blocks/llm.py`). Do NOT require the dot-separated form in Anthropic contexts. Only OpenRouter routing variants should use the dot separator (e.g., `anthropic/claude-opus-4.6`); `claude-opus-4-6` should be treated as correct when passed to Anthropic, and flagged only if it’s used in the OpenRouter path where the dot form is expected.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
📚 Learning: 2026-04-15T02:43:36.890Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 12780
File: autogpt_platform/backend/backend/copilot/tools/workspace_files.py:0-0
Timestamp: 2026-04-15T02:43:36.890Z
Learning: When reviewing Python exception handlers, do not flag `isinstance(e, X)` checks as dead/unreachable if the caught exception `X` is a subclass of the exception type being handled. For example, if `X` (e.g., `VirusScanError`) inherits from `ValueError` (directly or via an intermediate class) and it can be raised within an `except ValueError:` block, then `isinstance(e, X)` inside that handler is reachable and should not be treated as dead code.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
📚 Learning: 2026-04-22T11:46:04.431Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12881
File: autogpt_platform/backend/backend/copilot/config.py:0-0
Timestamp: 2026-04-22T11:46:04.431Z
Learning: Do not flag the Claude Sonnet 4.6 model ID as incorrect when it uses the project’s established hyphenated convention: `anthropic/claude-sonnet-4-6`. This hyphen form is the intentional, production convention and should be treated as valid (including in files like llm.py, blocks tests, reasoning.py, `_is_anthropic_model` tests, and config defaults). Note that OpenRouter also accepts the dot variant `anthropic/claude-sonnet-4.6`, so either form may be tolerated, but `anthropic/claude-sonnet-4-6` should be considered the standard to match project usage.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
📚 Learning: 2026-04-22T11:46:12.892Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12881
File: autogpt_platform/backend/backend/copilot/baseline/service.py:322-332
Timestamp: 2026-04-22T11:46:12.892Z
Learning: In this codebase (Significant-Gravitas/AutoGPT), OpenRouter-routed Anthropic model IDs should use the hyphen-separated convention (e.g., `anthropic/claude-sonnet-4-6`, `anthropic/claude-opus-4-6`). Although OpenRouter may accept both hyphen and dot variants, treat the hyphen-separated form as the intended, correct codebase-wide convention and do not flag it as an error. Only flag the dot-separated variant (e.g., `anthropic/claude-sonnet-4.6`) as incorrect when reviewing/validating model ID strings for OpenRouter-routed Anthropic models.
Applied to files:
autogpt_platform/backend/backend/api/features/integrations/router.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.pyautogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
📚 Learning: 2026-04-08T17:28:23.439Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/AGENTS.md:0-0
Timestamp: 2026-04-08T17:28:23.439Z
Learning: Applies to autogpt_platform/backend/**/*_test.py : Mock at boundaries — mock where the symbol is **used**, not where it's **defined**; after refactoring, update mock targets to match new module paths
Applied to files:
autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
📚 Learning: 2026-02-04T16:49:42.490Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-02-04T16:49:42.490Z
Learning: Applies to autogpt_platform/backend/**/test/**/*.py : Use snapshot testing with '--snapshot-update' flag in backend tests when output changes; always review with 'git diff'
Applied to files:
autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
📚 Learning: 2026-04-08T17:28:23.439Z
Learnt from: CR
Repo: Significant-Gravitas/AutoGPT PR: 0
File: autogpt_platform/backend/AGENTS.md:0-0
Timestamp: 2026-04-08T17:28:23.439Z
Learning: Applies to autogpt_platform/backend/**/*_test.py : When creating snapshots in tests, use `poetry run pytest path/to/test.py --snapshot-update`; always review snapshot changes with `git diff` before committing
Applied to files:
autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
📚 Learning: 2026-04-03T13:50:10.521Z
Learnt from: Pwuts
Repo: Significant-Gravitas/AutoGPT PR: 12206
File: autogpt_platform/backend/backend/api/external/v2/integrations/helpers.py:25-46
Timestamp: 2026-04-03T13:50:10.521Z
Learning: In `autogpt_platform/backend/backend/api/external/v2/integrations/helpers.py`, `CredentialInfo.from_internal` is intentionally a read-only external API view that exposes only: id, type, provider, title, scopes, expires_at. It omits internal metadata and secret fields by design. Do not flag omitted fields in CredentialInfo as missing information — the limited field set is the correct external API contract.
Applied to files:
autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.pyautogpt_platform/backend/backend/integrations/managed_credentials.py
🔇 Additional comments (2)
autogpt_platform/backend/backend/integrations/managed_credentials.py (1)
47-64: Docs accurately match gate ordering in_ensure_one.The two-gate description (
auto_provisionchecked beforeis_available) is consistent with_ensure_oneat lines 185-190, and the note that opt-out providers stay registered forcleanup_managed_credentials/ensure_managed_credentialmatches the registry and on-demand entry-point. Good clarification.autogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py (1)
119-121: No remaining references to old helper name found.The ripgrep search across the codebase confirms no references to
_read_or_create_profile_keyexist. The rename to_migrate_legacy_or_create_profile_keyis clean.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #12908 +/- ##
==========================================
+ Coverage 68.08% 68.10% +0.01%
==========================================
Files 1920 1920
Lines 149235 149236 +1
Branches 15554 15555 +1
==========================================
+ Hits 101612 101636 +24
+ Misses 44604 44576 -28
- Partials 3019 3024 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Why
Review comments on #12883 (thanks @Pwuts) surfaced a few spots where the managed-credential plumbing's names and docstrings didn't match what the code actually does:
_read_or_create_profile_keysuggests "read from any source or create new", but only migrates the legacymanaged_credentials.ayrshare_profile_keyside-channel — it doesn't read an existing managed credential. (That check lives in the outer_provision_under_lock.)/credentialsfetches.is_available/auto_provisionrelationship wasn't explicit; readers couldn't tell whetheris_availablewas a config check or a liveness check, or which of the two gates the sweep checks first.What
Naming + docstring cleanup. Zero behavior changes.
_read_or_create_profile_key→_migrate_legacy_or_create_profile_keywith docstring explaining why it doesn't re-check the managed cred.ManagedCredentialProviderclass docstring now names the two gates:auto_provision— does this provider participate in the sweep at all?is_available— are the required env vars / secrets set?is_availabledocstring now spells out: what it checks (env vars), what it does NOT check (upstream health), and that it's only consulted whenauto_provision=True.ensure_managed_credentialsdocstring defines "credentials sweep", when it fires, how the per-user in-memory cache works.How
4 files, all backend:
backend/integrations/managed_credentials.pybackend/integrations/managed_providers/ayrshare.pybackend/integrations/managed_providers/ayrshare_test.pybackend/api/features/integrations/router.pyTests: 13/13 Ayrshare tests pass against the rename.
Checklist