Skip to content

Conversation

@gemammercado
Copy link
Contributor

Filled in the autocomplete test for a JSON document. Test failing

@gemammercado gemammercado force-pushed the e2e-test branch 3 times, most recently from e17e954 to a27b368 Compare October 6, 2025 18:30
@github-actions
Copy link

github-actions bot commented Oct 6, 2025

Package Line Rate Branch Rate Complexity Health
ai 22% 80% 0
ai.llm 53% 80% 0
app 0% 0% 0
artifacts 100% 100% 0
auth 87% 92% 0
autocomplete 93% 91% 0
context 96% 96% 0
context.semantic 98% 97% 0
context.semantic.parameter 100% 95% 0
context.syntaxtree 90% 91% 0
context.syntaxtree.utils 86% 91% 0
datastore 77% 97% 0
definition 100% 100% 0
document 93% 96% 0
documentSymbol 93% 81% 0
handlers 75% 88% 0
hover 85% 86% 0
protocol 96% 100% 0
resourceState 76% 80% 0
schema 88% 87% 0
schema.transformers 87% 85% 0
server 97% 96% 0
services 67% 89% 0
services.cfnLint 72% 91% 0
services.guard 95% 79% 0
services.guard.assets 81% 77% 0
settings 97% 87% 0
stacks 100% 100% 0
telemetry 58% 78% 0
templates 89% 85% 0
utils 91% 92% 0
Summary 86% (17087 / 19775) 89% (3542 / 3973) 0

@Zee2413
Copy link
Contributor

Zee2413 commented Oct 7, 2025

Why are we deleting the YamlBlankLinesCompletion test?

position: { line: 127, character: 15 },
expectation: CompletionExpectationBuilder.create()
.expectContainsItems(['Fn::FindInMap'])
.todo() //Autocomplete looks for Fn or ! in YAML for Intrinsic Function
Copy link
Contributor

Choose a reason for hiding this comment

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

yaml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ignore the YAML that was for my understanding. The important part is that when looking for an intrinsic function in JSON the router expects "Fn:" to set the shouldUseIntrinsicFunctionProvider to true (CompletionRouter.ts, line 236). The "Fi" doesn't go through the if block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try to add a fix to make this more function more robust.

position: { line: 127, character: 69 },
expectation: CompletionExpectationBuilder.create()
.expectContainsItems(['InstanceType'])
.todo() //returns nothing in valid JSON
Copy link
Contributor

Choose a reason for hiding this comment

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

really? does this match functional testing observation?

Copy link
Contributor Author

@gemammercado gemammercado Oct 7, 2025

Choose a reason for hiding this comment

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

I haven't checked it in functional testing, but I think the issue is that, getSecondLevelKeyCompletions (IntrinsicFunctionArgumentProvider.ts, line 512) returns undefined. The current line in the JSON looks like:
{"Fn::FindInMap": ["RegionMap", {"Ref": "AWS::Region"}, "I"]}
The second argument is an object at parse time so it goes through this if block:

if (!Array.isArray(args) || args.length < 2 || typeof args[0] !== 'string' || typeof args[1] !== 'string') {
            log.debug('Invalid arguments for second-level key completions');
            return undefined;
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I messed around with the code and found another issue with getSecondLevelKeyCompletions:
Even if after this line
{"Fn::FindInMap": ["RegionMap", {"Ref": "AWS::Region"}, "I"]}
We read in the dynamic topLevelKey as valid, the code will return undefined at this check:

            const secondLevelKeys = mappingEntity.getSecondLevelKeys(topLevelKey);
            if (secondLevelKeys.length === 0) {
                console.log(`No second-level keys found for mapping: ${mappingName}, top-level key: ${topLevelKey}`);
                return undefined;
            }

getSecondLevelKeys expects a string parameter, so passing in the reference will return [] with length 0.

position: { line: 477, character: 14 },
expectation: CompletionExpectationBuilder.create()
.expectItems(['Value'])
.todo() //works in real template not in e2e
Copy link
Contributor

Choose a reason for hiding this comment

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

that should never happen. see if we can figure out the inconsistency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also what happens in YAML. The comment is actually just a copy of the comment for this step in the YAML test. Will look into both cases.

@@ -1,270 +0,0 @@
import { describe, it } from 'vitest';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this test removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a mistake, was not supposed to be in the commit

position: { line: 580, character: 79 },
expectation: CompletionExpectationBuilder.create()
.expectItems(['AMI'])
.todo() //Returns nothing for both JSON and YAML
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to add a parameter to the todo function that explains why the todo is there, instead of using inline comments to explain the reason for todo

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed

@gemammercado gemammercado marked this pull request as draft October 13, 2025 15:12
@satyakigh satyakigh deleted the e2e-test branch December 7, 2025 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants