"Failed to import snippets" after adding sample snippet to ADS - no custom snippets in SSMS

TrailBearTrailBear Posts: 2 New member
I want to add one new user snippet to ADS, but SQL Prompt is throwing an error. 
Further, while experimenting I see that if I add only comments to the ADS sql.json, that they get erased. 

Redgate SQL Prompt Version 0.2.10 in ADS 1.36.2

Added just the "select top 5" sample snippet from Create reusable code snippets - Azure Data Studio | Microsoft Docs to the ADS sql.json snippets and get 
<div>Failed to import snippets from SSMS: Error: Unhandled exception: System.Text.Json.JsonException: The JSON value could not be converted to System.String. Path: <b>$['Select top 5'].body</b> | LineNumber: 3 | BytePositionInLine: 51.</div><div></div>
I have no custom snippets in SSMS or Visual Studio to import, so not sure what value this is adding.  
Tagged:

Answers

  • Dan_JDan_J Posts: 464 Silver 2
    Hi @TrailBear

    Our apology for not responding to you on this before now!

    As a ticket has been logged for this, I will continue to communicate with you via that ticket.


    Kind regards

    Dan Jary | Redgate Software
    Have you visited our Help Center?
  • Sharing some details on what may be occurring with snippets and a potential workaround,

    SQL Prompt attempts to sync the snippets from SSMS/VS when launching ADS.
    It is using the sql.json file for this. 
    If external code is introduced into the file it looks to break this process. 
     
    There also looks to be a difference in how SQL Prompt snippets & ADS snippets handle placeholders.
    Prompt wraps placeholders in $$ and ADS uses the one $ at the start. 
    So when attempting to read the ADS snippet in the SQL Prompt format it generates the error.
     
    I believe the workaround here is to keep SSMS/SQL Prompt snippets only in the sql.json file and create a separate snippet file for other code.
     
    For my testing I had created a global snippet file and saved the code snippet from your website in it, then I allowed Prompt to maintain the sql.json file.
    Both files resided in my ADS snippet folder
    C:\Users\<user>\AppData\Roaming\azuredatastudio\User\snippets and I could use all snippets in my project.

    Hope this helps for any users of ADS and SQL Prompt trying to maintain multiple sources of snippets
    Jon Kirkwood | Technical Support Engineer | Redgate Software
Sign In or Register to comment.