How can we help you today? How can we help you today?

Unable to save changes in snippet manager

I have many snippets I've created the past few years and I was trying to clean up. If I delete any snippet I am unable to save changes (clicking Ok). I get the below modal. I have version: 10.13.12.1701



Stack trace from the logs.

2023-07-29 23:43:19.467 -07:00 [Error] Failed to save settings due to snippet error.
System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at RedGate.SqlPrompt.CommonUI.Options.Pages.Snippets.ViewModels.SnippetsPageViewModel.SaveChangesToModel()
   at RedGate.SqlPrompt.CommonUI.Options.Pages.Suggestions.SnippetsPage.Save()
   at RedGate.SqlPrompt.CommonUI.Options.OptionsForm.OnOkButtonClicked(Object sender, EventArgs e)
Bobby_Tables
0

Comments

2 comments

  • Bobby_Tables
    I resoved the issue myself but had to review the json files in the snippets folder and it looked like some had duplicate names even though the guid was different. After removing the suspected files it started working again.
    Bobby_Tables
    0
  • mark.rovendro

    I am receiving the “Failed to save settings due to snipper error. An item with the same key as already been added” I have reviewed all the files in my Snippet folder looking at the full name along with just the command portion of the name and there are no duplicates. 

    I was changing a Inserted code > Objects & Statements setting when I got the message clicking on Ok. I did not even make any changes to the Snippets.

    Version 11.3.17.25200

     

    28676 2026-07-08 08:02:43.723 -04:00 [Error] Failed to save settings due to snippet error.
    [Outer exception] System.ArgumentException : An item with the same key has already been added.
      at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
      at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
      at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
      at RedGate.SqlPrompt.CommonUI.Options.Pages.Snippets.ViewModels.SnippetsPageViewModel.SaveChangesToModel()
      at RedGate.SqlPrompt.CommonUI.Options.OptionsForm.OnOkButtonClicked(Object sender, EventArgs e)

    mark.rovendro
    0

Add comment

Please sign in to leave a comment.