Admin Filtros - Tratar o caracter plique da forma correta nos filtros do admin

Produtos & SKU

Aberto
Cris David

Cris David

Última atualização

Sumário

Os campos “txtTextoLivre” dos filtros do admin não estão tratando corretamente o caracter ‘ (plique ou aspa simples). Quando um usuário aplica um filtro (usando o campo txtTextoLivre) com um termo que possui esse caracter (plique), o sistema retorna erro:

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Data.SqlClient.SqlException (0x80131904): Unclosed quotation mark after the character string ') GROUP BY P.[Id],P.[BrandId],P.[RefId],P.[CategoryId],P.[DepartmentId],P.[IsActive],P.[IsVisible],P.[LinkId],P.[Name],P.[Description],P.[DescriptionShort],P.[ReleaseDate],P.[KeyWords],P.[Title],P.[TaxCode],P.[AdWordsRemarketingCode],P.[MetaTagDescription],P.[DateUpdated],P.[SupplierId],P.[LomadeeCampaignCode],P.[ShowWithoutStock],P.[SuggestedGlobalCategoryId],P.[AcceptedGlobalCategoryId],P.[EditionAdminId],P.[ApprovedAdminId],P.[EditionProductId],P.[Score] ) SELECT [Id], [BrandId], [RefId], [CategoryId], [DepartmentId], [IsActive], [IsVisible], [LinkId], [Name], [Description], [DescriptionShort], [ReleaseDate], [KeyWords], [Title], [TaxCode], [AdWordsRemarketingCode], [MetaTagDescription], [DateUpdated], [SupplierId], [LomadeeCampaignCode], [ShowWithoutStock], [SuggestedGlobalCategoryId], [AcceptedGlobalCategoryId], [EditionAdminId], [ApprovedAdminId], [EditionProductId], [Score], (SELECT COUNT(1) FROM __vtexOrderByTable) AS TotalRows FROM __vtexOrderByTable WHERE __vtexOrderByField BETWEEN @startRowIndex AND @startRowIndex + @maximumRows - 1; SET NOCOUNT OFF;'. Incorrect syntax near ') GROUP BY P.[Id],P.[BrandId],P.[RefId],P.[CategoryId],P.[DepartmentId],P.[IsActive],P.[IsVisible],P.[Link'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteReader(DbCommand command, CommandBehavior cmdBehavior) at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteReader(DbCommand command) at Vtex.Commerce.CatalogSystem.DataStore.SqlServer.ProductDalc.GetAllPagedAndFiltered(Int32 startRowIndex, Int32 maximumRows, String filters, String sortOrder) at Vtex.Commerce.CatalogSystem.ProductFactory.<>c__DisplayClass40.<GetAllPagedAndFiltered>b__3f() at Vtex.Practices.Caching.Core.CacheManager.<>c__DisplayClass92_0`1.<GetInternal>b__0() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at Vtex.Practices.Caching.Core.CacheManager.GetInternalAlmostThreadSafe[T](String completeKey, Func`1 backEndFuncWrapped, Boolean isTask, Boolean forceRefresh) at Vtex.Commerce.CatalogSystem.ProductFactory.GetAllPagedAndFiltered(Int32 startRowIndex, Int32 maximumRows, String filters, String sortOrder) at AdminWebSite.Site.Produto.ListProducts() at AdminWebSite.Site.Produto.ListarProdutos() at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Control.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) ClientConnectionId:6bc42c51-ec5f-47bd-aa70-65368bb48f64 Error Number:105,State:1,Class:15 at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Simulação

Na tela de produto, por exemplo, o erro acontece ao se tentar filtrar pelos campos abaixo:

  • EAN (txtTextoLivre1);
  • Código de referência (RefId) do Produto (txtTextoLivre2);
  • Código de referência (RefId) do SKU (txtTextoLivre3);
  • Como referência, o campo Nome do Produto não apresenta o erro.

Página: https://lojadosuporte.vtexcommercestable.com.br/admin/site/Produto.aspx

O impacto é que o usuário não consegue mais acessar a página em questão pois o termo fica guardado no banco de dados como último filtro. O acesso apenas é restabelecido quando limpamos os filtros do usuário pelo admin.

Workaround

A única solução paliativa existente para esse cenário é criar um novo usuário. Esta é a única ação que o lojista consegue realizar sozinho capaz de corrigir o problema. Fora isso, o lojista deve entrar em contato com a VTEX para que possamos limpar o filtro do usuário afetado.