ref(integrations): Refactor platform detection to composable framework definitions#109700
Merged
ref(integrations): Refactor platform detection to composable framework definitions#109700
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
61cacd1 to
0815067
Compare
This was referenced Mar 2, 2026
0815067 to
efa46fe
Compare
782090f to
40dfe37
Compare
4b8dc2a to
0d660b0
Compare
40dfe37 to
f28708b
Compare
574a5b8 to
8d5b597
Compare
e78d4fc to
393982c
Compare
2ae4a7f to
b30fee7
Compare
b30fee7 to
5d8136e
Compare
45a50d5 to
59ed13c
Compare
f1037d2 to
e727af9
Compare
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
tests/sentry/integrations/api/endpoints/test_organization_repository_platforms.py
Show resolved
Hide resolved
Contributor
Backend Test FailuresFailures on
|
jaydgoss
added a commit
that referenced
this pull request
Mar 12, 2026
## Summary
- Add `get_languages()` method to GitHub API client to fetch repository
language statistics
- Create `platform_detection` module with language-to-platform mapping,
framework detection from manifest files (package.json, requirements.txt,
pyproject.toml, Pipfile, Gemfile, composer.json, build.gradle, pom.xml,
go.mod), and confidence scoring
- Add REST endpoint `GET
/api/0/organizations/{org}/repos/{repo_id}/platforms/` to expose
detected platforms
- 18 base language mappings, 23 framework detection rules, 24 ignored
languages
This is the foundation for automatic platform detection from GitHub
repositories to streamline onboarding. Part 1 of 3.
**Stack:**
- **PR 1 (this):** Core detection + API endpoint
- [PR 2](#109700): Composable
framework definitions refactor
- [PR 3](#109701): Expanded
coverage (~80 platforms)
## Test plan
- 44 unit tests covering language mapping, manifest parsing, framework
detection, supersession, and edge cases
- 7 integration tests covering endpoint success/error cases, IDOR
prevention, and auth requirements
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Base automatically changed from
jaygoss/vdy-15-platform-detection-core
to
master
March 12, 2026 16:06
…k definitions Replace flat framework detection with a composable FrameworkDef / DetectorRule system inspired by Vercel's framework detection. Each framework is a self-contained definition with three signal types: path (config file existence), match_content (regex on file content), and match_package (dependency lookup in parsed manifests). Add every (AND) and some (OR) rule composition, priority ranking via sort field, and supersession so meta-frameworks like Next.js remove redundant base frameworks like React from results. Batch file content fetching into a single pass to minimize GitHub API calls. Co-Authored-By: Claude <noreply@anthropic.com>
…types
Use `or {}` instead of `.get(key, {})` when accessing dependency fields
in package.json and composer.json parsing. When a field is explicitly
null (e.g., `"dependencies": null`), `.get()` returns None instead of
the default, causing an AttributeError on `.keys()`.
Also change FrameworkDef from `total=False` to use NotRequired for
optional fields only, so the type checker enforces that platform, sort,
and base_platform are always present.
Co-Authored-By: Claude <noreply@anthropic.com>
Catch KeyError, TypeError, and AttributeError in addition to ApiError when parsing the GitHub Contents API response. Handles cases where items are missing the "name" field or the response is not a list. Co-Authored-By: Claude <noreply@anthropic.com>
Annotate inline dict literals with DetectorRule and FrameworkDef types so mypy recognizes them as compatible TypedDict instances rather than plain dict[str, str] or dict[str, object]. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Skip items missing "name" key instead of discarding all results. Previously a single malformed item would cause KeyError, caught by the blanket except, returning an empty set for the entire listing. Co-Authored-By: Claude <noreply@anthropic.com>
…n tests Add TestFrameworksIntegrity to catch structural errors in framework definitions: duplicate platform IDs, invalid base_platforms, dangling supersedes targets, missing rules, and match_content without path. Add TestDetectPlatformsMultiStack to exercise the full pipeline against a realistic repo with Python (Django + Celery), JavaScript (Next.js), Go (Gin), TypeScript, and ignored languages — validating framework detection, supersession, priority ordering, and language filtering all work together. Co-Authored-By: Claude <noreply@anthropic.com>
The detection pattern is a common technique, not derived from Vercel's code. Remove references to avoid implying a stronger connection than exists. Co-Authored-By: Claude <noreply@anthropic.com>
- Fold None-manifest check into _package_in_manifest - Simplify _framework_matches since all([]) returns True - Rename detected_ids to platform_ids Co-Authored-By: Claude <noreply@anthropic.com>
…amework tier Sort by (bytes, priority) instead of (priority, bytes) so that the dominant language in a repo ranks first. Previously a JS meta-framework like Next.js would always outrank Django even in a Python-majority repo. Now sort values only control ordering within a language group. Co-Authored-By: Claude <noreply@anthropic.com>
Restore full response assertions that were lost during rebase conflict resolution. Tests now verify the complete response dict including platform, language, bytes, confidence, and priority fields. Co-Authored-By: Claude <noreply@anthropic.com>
…ting fails _get_root_file_names now returns None on API failure instead of an empty set, so detect_platforms can distinguish "API failed" from "empty repo root". When the root listing is unavailable, content-based and package-based framework detection still works by fetching files individually rather than silently degrading to base platforms only.
…language result" This reverts commit 1d0182a.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FrameworkDef/DetectorRulesystempath(config file existence),match_content(regex on file content),match_package(dependency lookup in parsed manifests)every(AND) andsome(OR) rule compositionsortfield) and supersession (e.g. Next.js supersedes React)No behavior change for existing detections, but the architecture now supports easy addition of new frameworks as data-only entries.
Stack: