TypeScript ScanningRecipe sends no edit preconditions over RPC
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 69/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java, javascript, typescript
- Domain
- backend-api-design, devtools
Research direction
Start by reading ScanningRecipe.editor() and PrepareRecipe.optimizePreconditions in the TypeScript package, then compare the plain and scanning recipe repro in the issue. Trace why the lazy editor wrapper hides the visitor type or check() from precondition optimization. Done means the scanning recipe produces the appropriate edit precondition and the host no longer sends incompatible source files to its edit visitor.
Written by the indexing model from the issue text.
Description
In @openrewrite/rewrite 8.100.3, PrepareRecipe sends no editPreconditions for a TypeScript ScanningRecipe. ScanningRecipe.editor() returns a lazy wrapper around editorWithData, so optimizePreconditions never sees the editor's visitor type or its check(). The host then sends every source file to the edit visitor. A Python requirements.txt fails with No RPC codec registered on the TypeScript side for 'org.openrewrite.python.marker.PythonResolutionResult'.
Repro (npm i @openrewrite/[email protected]):
const {Recipe, ScanningRecipe} = require("@openrewrite/rewrite");
const {JsonVisitor} = require("@openrewrite/rewrite/json");
const {PrepareRecipe} = require(require.resolve("@openrewrite/rewrite").replace(/index\.js$/, "rpc/request/prepare-recipe.js"));
class Plain extends Recipe { name = "repro.plain"; displayName = "plain"; description = "plain"; async editor() { return new JsonVisitor(); } }
class Scanning extends ScanningRecipe {
name = "repro.scanning"; displayName = "scanning"; description = "scanning";
initialValue() { return {}; }
async scanner() { return new JsonVisitor(); }
async editorWithData() { return new JsonVisitor(); }
}
(async () => {
for (const r of [new Plain(), new Scanning()]) {
const pre = [];
await PrepareRecipe.optimizePreconditions(r, "edit", pre);
console.log(r.name, JSON.stringify(pre));
}
})();
Output: repro.plain gets the FindTreesOfType Json gate; repro.scanning gets [].
Seen with Moderne CLI 4.13.0-SNAPSHOT on splunk/splunk-app-examples, running org.openrewrite.react.migrate.enzyme-to-react-testing-library. Related: #9582 (scan batching, fixed by #9669).
- Dominant language
- Java
- Stars
- 3.9k
- Forks
- 599
- Avg merge
- 9h 38m
- Merged PRs (30d)
- 557
Getting set up
- No Dockerfile or Docker Compose file
- No 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 openrewrite/rewrite
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
openrewrite/rewrite#9835 ·
Maintainers usually reply within 1 day
-
bug gradle
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
openrewrite/rewrite#7576 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
openrewrite/rewrite#9834 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
openrewrite/rewrite#9819 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 55/100
openrewrite/rewrite#9817 ·
Maintainers usually reply within 1 day
All issues in openrewrite/rewrite
Similar issues
-
Four TestConstraintBasedAlgorithm tests pass when nothing is thrownPossibly taken @sharanggupta claimed this today. Open
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
-
bug documentation good first issue help wanted priority low size XS
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
martin-francois/symphony-trello#1351 ·
Maintainers usually reply within 1 day
-
Add test coverage for ConvertUtil.parseDate() with NULL inputPossibly taken @mirajul-mollah7 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 78/100
eclipse-sw360/sw360#4792 · 1 comment ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws/aws-emulator#30 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 4 days