Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle missing prompts in custom commands #3012

Merged
merged 6 commits into from
Feb 2, 2024
Merged

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Feb 2, 2024

context: https://sourcegraph.slack.com/archives/C04MSD3DP5L/p1706656724966049

fix: handle commands missing prompts when building map

Issue: Currently, an invalid entry in the cody.json will cause custom commands not showing up in the command menu.

Fix: Updated the get-commands utility to skip adding commands to the map if they don't contain a prompt property. It updates the command type and adds null checking before accessing the prompt property.

This prevents crashes when building the custom command map if a command is missing the expected prompt field.

Test plan

Updated both the unit test and e2e test to ensure an invalid custom command entry would not break the custom command at build time.

Create a custom command entry without adding a prompt in your cody.json.

Before: all your custom command from that file will not show up in the custom command menu.

After: only the invalid ones will not show up in the menu, while the valid ones do.

@abeatrix abeatrix requested a review from a team February 2, 2024 11:19
vscode/src/commands/utils/get-commands.ts Outdated Show resolved Hide resolved
@abeatrix abeatrix merged commit 26c67db into main Feb 2, 2024
15 checks passed
@abeatrix abeatrix deleted the bee/fix-custom-prompt branch February 2, 2024 16:35
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.

None yet

3 participants