Skip to content

refactor(backend/integrations): clearer naming + docs for managed-cred sweep - #12908

Merged
majdyz merged 1 commit into
devfrom
refactor/managed-creds-clearer-naming
Apr 24, 2026
Merged

refactor(backend/integrations): clearer naming + docs for managed-cred sweep#12908
majdyz merged 1 commit into
devfrom
refactor/managed-creds-clearer-naming

Conversation

@majdyz

@majdyz majdyz commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

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_key suggests "read from any source or create new", but only migrates the legacy managed_credentials.ayrshare_profile_key side-channel — it doesn't read an existing managed credential. (That check lives in the outer _provision_under_lock.)
  • Docstrings refer to "the startup sweep" in several places — there's no startup hook; the sweep runs on /credentials fetches.
  • is_available / auto_provision relationship wasn't explicit; readers couldn't tell whether is_available was a config check or a liveness check, or which of the two gates the sweep checks first.

What

Naming + docstring cleanup. Zero behavior changes.

  • Rename _read_or_create_profile_key_migrate_legacy_or_create_profile_key with docstring explaining why it doesn't re-check the managed cred.
  • Replace "startup sweep" → "credentials sweep" everywhere.
  • ManagedCredentialProvider class docstring now names the two gates:
    1. auto_provision — does this provider participate in the sweep at all?
    2. is_available — are the required env vars / secrets set?
  • is_available docstring now spells out: what it checks (env vars), what it does NOT check (upstream health), and that it's only consulted when auto_provision=True.
  • ensure_managed_credentials docstring defines "credentials sweep", when it fires, how the per-user in-memory cache works.
  • Module-level docstring drops the stale "non-blocking background task" wording (refactor(platform): migrate Ayrshare to standard managed-credential flow #12883 made the sweep bounded-await).

How

4 files, all backend:

  • backend/integrations/managed_credentials.py
  • backend/integrations/managed_providers/ayrshare.py
  • backend/integrations/managed_providers/ayrshare_test.py
  • backend/api/features/integrations/router.py

Tests: 13/13 Ayrshare tests pass against the rename.

Checklist

  • Follows style guide
  • Existing tests still pass (no functional change)
  • No new tests needed — pure rename + docstring change

…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.
@majdyz
majdyz requested a review from a team as a code owner April 24, 2026 07:36
@majdyz
majdyz requested review from Bentlybro and Swiftyos and removed request for a team April 24, 2026 07:36
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Apr 24, 2026
@github-actions github-actions Bot added the platform/backend AutoGPT Platform - Back end label Apr 24, 2026
@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The 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

Cohort / File(s) Summary
Documentation & Comment Updates
autogpt_platform/backend/backend/api/features/integrations/router.py, autogpt_platform/backend/backend/integrations/managed_credentials.py, autogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
Updated module and function docstrings to formalize the "credentials sweep" model, clarify provisioning gates (auto_provision checked before is_available), document sweep triggers and caching semantics, and explain that is_available() performs pure environment-variable checks without external service calls. Changed inline comment references from "startup sweep" to "credentials sweep" for consistency.
Internal Helper Rename & Tests
autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
Updated test imports and call sites to use the renamed internal helper _migrate_legacy_or_create_profile_key (previously _read_or_create_profile_key) with matching docstring updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

size/m, platform/backend

Suggested reviewers

  • 0ubbe
  • kcze
  • Pwuts
  • Swiftyos

Poem

🐰 A rabbit hops through docs with glee,
"Sweep" now clear for all to see!
Credentials flow, migration rite,
Comments fixed, the path shines bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: a refactor of backend integration code to improve naming clarity and documentation for the managed-credential sweep feature.
Description check ✅ Passed The description is directly related to the changeset, providing clear context for why the changes were made and what was updated across all four modified files.
Docstring Coverage ✅ Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/managed-creds-clearer-naming

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Overlap Detection

This check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early.

🟢 Low Risk — File Overlap Only

These 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: openapi.json, lock files.

@majdyz
majdyz requested a review from Pwuts April 24, 2026 07:38
@majdyz
majdyz enabled auto-merge April 24, 2026 07:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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_key to better reflect intent. The enclosing test class TestReadOrCreateProfileKey is now named after the old helper and works against the PR's naming-clarity goal. Consider renaming to e.g. TestMigrateLegacyOrCreateProfileKey for 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3aa72b4 and 2269330.

📒 Files selected for processing (4)
  • autogpt_platform/backend/backend/api/features/integrations/router.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare.py
  • autogpt_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: Use poetry run ... command for executing Python package dependencies
Use top-level imports only — avoid local/inner imports except for lazy imports of heavy optional dependencies like openpyxl
Use absolute imports with from 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 — avoid hasattr/getattr/isinstance for 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 %s for deferred interpolation in debug log statements for efficiency; use f-strings elsewhere for readability (e.g., logger.debug("Processing %s items", count) vs logger.info(f"Processing {count} items"))
Sanitize error paths by using os.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
Use transaction=True for Redis pipelines to ensure atomicity on multi-step operations
Use max(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.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_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.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_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: Use Security() instead of Depends() for authentication dependencies to get proper OpenAPI security specification
Follow SSE (Server-Sent Events) protocol: use data: lines for frontend-parsed events (must match Zod schema) and : comment lines 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.py naming 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
Use AsyncMock from unittest.mock for async functions in tests
When writing tests, use Test-Driven Development (TDD): write failing tests marked with @pytest.mark.xfail before implementation, then remove the marker once the implementation is complete
When creating snapshots in tests, use poetry run pytest path/to/test.py --snapshot-update; always review snapshot changes with git diff before 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.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_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.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_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.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_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.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_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.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_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.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_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.py
  • autogpt_platform/backend/backend/integrations/managed_providers/ayrshare_test.py
  • autogpt_platform/backend/backend/integrations/managed_credentials.py
  • autogpt_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.py
  • autogpt_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_provision checked before is_available) is consistent with _ensure_one at lines 185-190, and the note that opt-out providers stay registered for cleanup_managed_credentials/ensure_managed_credential matches 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_key exist. The rename to _migrate_legacy_or_create_profile_key is clean.

@codecov

codecov Bot commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.10%. Comparing base (3aa72b4) to head (2269330).
⚠️ Report is 1 commits behind head on dev.

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     
Flag Coverage Δ
platform-backend 77.77% <100.00%> (-0.01%) ⬇️
platform-frontend-e2e 30.22% <ø> (+0.35%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 77.77% <100.00%> (-0.01%) ⬇️
Platform Frontend 32.22% <ø> (+0.11%) ⬆️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@majdyz
majdyz disabled auto-merge April 24, 2026 09:22
@majdyz
majdyz merged commit ab88d03 into dev Apr 24, 2026
40 checks passed
@majdyz
majdyz deleted the refactor/managed-creds-clearer-naming branch April 24, 2026 09:22
@github-project-automation github-project-automation Bot moved this from 🆕 Needs initial review to ✅ Done in AutoGPT development kanban Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/backend AutoGPT Platform - Back end size/l

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

1 participant