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

[Unique Field] : Recalculating more than one unique field when using uniquePerSite is failing #30892

Open
jcastro-dotcms opened this issue Dec 9, 2024 · 2 comments

Comments

@jcastro-dotcms
Copy link
Contributor

jcastro-dotcms commented Dec 9, 2024

Parent Issue

Problem Statement

The uniquePerSite Field Variable enables/disables the possibility of having Contentlets with the exact same unique value, but living under different Sites. When you have a Content Type with more than one unique field, and try to add the uniquePerSite Field Variable in one of them, dotCMS is returning an error.

Steps to Reproduce

  • In your docker-sompose.yml file, enable the feature flag:
DOT_FEATURE_FLAG_DB_UNIQUE_FIELD_VALIDATION: true
  • Start dotCMS with the Full Starter.
  • Create a Content Type named My CT.
  • Add two unique Text fields:
    • Title
    • Number
  • Create two test Contentlets of such a type:
    • First Contentlet:
      • Title = 111
      • Number = 222
    • Second Contentlet:
      • Title = 333
      • Number = 444
  • Go to the definition of the Title field, and try to add the uniquePerSite Field Variable.
  • The following error shows up in the UI:
Screenshot 2024-12-09 at 10 58 22 AM
  • This is just part of the error in the log file, as the stack trace is huge:
dotcms-1      | com.dotcms.contenttype.business.UniqueFieldValueDuplicatedException: Failed to recalculate unique value has for field 'title' in Content Type '070cda7fcda1ecf9c481dc4232ecc89e': ERROR: null value in column "unique_key_val" of relation "unique_fields" violates not-null constraint
dotcms-1      |   Detail: Failing row contains (null, {"live": true, "variant": "DEFAULT", "fieldValue": "111", "langu...).{
dotcms-1      |   "SQL": ["UPDATE unique_fields\nSET unique_key_val = encode(sha256(\n    jsonb_extract_path_text(supporting_values, 'contentTypeId')::bytea || \n    jsonb_extract_path_text(supporting_values, 'fieldVariableName')::bytea || \n    jsonb_extract_path_text(supporting_values, 'languageId')::bytea || \n    jsonb_extract_path_text(supporting_values, 'fieldValue')::bytea\n     || jsonb_extract_path_text(supporting_values, 'siteId')::bytea \n), 'hex'), \nsupporting_values = jsonb_set(supporting_values, '{uniquePerSite}', 'true') \nWHERE supporting_values->>'contentTypeId' = ?\nAND supporting_values->>'fieldVariableName' = ?"],
dotcms-1      |   "maxRows": [-1],
dotcms-1      |   "offest": [0],
dotcms-1      |   "params": [
dotcms-1      |     "070cda7fcda1ecf9c481dc4232ecc89e",
dotcms-1      |     "title"
dotcms-1      |   ]
dotcms-1      | }
dotcms-1      | 	at com.dotcms.contenttype.business.uniquefields.extratable.DBUniqueFieldValidationStrategy.recalculate(DBUniqueFieldValidationStrategy.java:268) ~[?:?]
dotcms-1      | 	at com.dotcms.contenttype.business.uniquefields.extratable.DBUniqueFieldValidationStrategy$Proxy$_$$_WeldClientProxy.recalculate(Unknown Source) ~[?:?]
dotcms-1      | 	at com.dotcms.contenttype.business.FieldAPIImpl.save(FieldAPIImpl.java:686) ~[?:?]
dotcms-1      | 	at com.dotcms.rest.api.v1.contenttype.FieldVariableResource.saveFieldVariable(FieldVariableResource.java:542) ~[?:?]
dotcms-1      | 	at com.dotcms.rest.api.v1.contenttype.FieldVariableResource.createFieldVariableByFieldId(FieldVariableResource.java:117) ~[?:?]
dotcms-1      | 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
dotcms-1      | 	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:253) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors.process(Errors.java:292) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors.process(Errors.java:274) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors.process(Errors.java:244) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:232) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:679) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:392) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:365) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:318) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.CMSFilter.doFilterInternal(CMSFilter.java:198) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.CMSFilter.doFilter(CMSFilter.java:59) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.filters.interceptor.AbstractWebInterceptorSupportFilter.doFilter(AbstractWebInterceptorSupportFilter.java:90) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.filters.interceptor.AbstractWebInterceptorSupportFilter.doFilter(AbstractWebInterceptorSupportFilter.java:90) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.visitor.filter.servlet.VisitorFilter.doFilter(VisitorFilter.java:81) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.vanityurl.filters.VanityURLFilter.doFilter(VanityURLFilter.java:107) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176) ~[?:?]
dotcms-1      | 	at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145) ~[?:?]
dotcms-1      | 	at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92) ~[?:?]
dotcms-1      | 	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.TimeMachineFilter.doFilter(TimeMachineFilter.java:137) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.ThreadNameFilter.doFilter(ThreadNameFilter.java:88) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.CookiesFilter.doFilter(CookiesFilter.java:53) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.CharsetEncodingFilter.doFilter(CharsetEncodingFilter.java:99) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.filters.interceptor.AbstractWebInterceptorSupportFilter.doFilter(AbstractWebInterceptorSupportFilter.java:90) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:129) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.filters.NormalizationFilter.doFilter(NormalizationFilter.java:89) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[?:?]
dotcms-1      | 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130) ~[?:?]
dotcms-1      | 	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:670) ~[?:?]
dotcms-1      | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[?:?]
dotcms-1      | 	at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:765) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[?:?]
dotcms-1      | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) ~[?:?]
dotcms-1      | 	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390) ~[?:?]
dotcms-1      | 	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[?:?]
dotcms-1      | 	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1732) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1295) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.Nio2Endpoint.setSocketOptions(Nio2Endpoint.java:339) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.Nio2Endpoint$Nio2Acceptor.completed(Nio2Endpoint.java:479) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.Nio2Endpoint$Nio2Acceptor.completed(Nio2Endpoint.java:415) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.Invoker.invokeDirect(Invoker.java:160) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.Invoker.invoke(Invoker.java:188) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.UnixAsynchronousServerSocketChannelImpl.onEvent(UnixAsynchronousServerSocketChannelImpl.java:194) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:305) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113) ~[?:?]
dotcms-1      | 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
dotcms-1      | 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
dotcms-1      | 	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
dotcms-1      | 16:58:15.043  ERROR mapper.DotDataExceptionMapper - null
dotcms-1      | com.dotmarketing.exception.DotDataException: null
dotcms-1      | 	at com.dotcms.contenttype.business.FieldAPIImpl.save(FieldAPIImpl.java:691) ~[?:?]
dotcms-1      | 	at com.dotcms.rest.api.v1.contenttype.FieldVariableResource.saveFieldVariable(FieldVariableResource.java:542) ~[?:?]
dotcms-1      | 	at com.dotcms.rest.api.v1.contenttype.FieldVariableResource.createFieldVariableByFieldId(FieldVariableResource.java:117) ~[?:?]
dotcms-1      | 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
dotcms-1      | 	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:253) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors.process(Errors.java:292) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors.process(Errors.java:274) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.internal.Errors.process(Errors.java:244) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:232) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:679) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:392) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:365) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:318) ~[?:?]
dotcms-1      | 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.CMSFilter.doFilterInternal(CMSFilter.java:198) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.CMSFilter.doFilter(CMSFilter.java:59) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.filters.interceptor.AbstractWebInterceptorSupportFilter.doFilter(AbstractWebInterceptorSupportFilter.java:90) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.filters.interceptor.AbstractWebInterceptorSupportFilter.doFilter(AbstractWebInterceptorSupportFilter.java:90) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.visitor.filter.servlet.VisitorFilter.doFilter(VisitorFilter.java:81) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.vanityurl.filters.VanityURLFilter.doFilter(VanityURLFilter.java:107) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176) ~[?:?]
dotcms-1      | 	at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145) ~[?:?]
dotcms-1      | 	at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92) ~[?:?]
dotcms-1      | 	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.TimeMachineFilter.doFilter(TimeMachineFilter.java:137) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.ThreadNameFilter.doFilter(ThreadNameFilter.java:88) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.CookiesFilter.doFilter(CookiesFilter.java:53) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotmarketing.filters.CharsetEncodingFilter.doFilter(CharsetEncodingFilter.java:99) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.filters.interceptor.AbstractWebInterceptorSupportFilter.doFilter(AbstractWebInterceptorSupportFilter.java:90) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:129) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at com.dotcms.filters.NormalizationFilter.doFilter(NormalizationFilter.java:89) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[?:?]
dotcms-1      | 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130) ~[?:?]
dotcms-1      | 	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:670) ~[?:?]
dotcms-1      | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[?:?]
dotcms-1      | 	at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:765) ~[?:?]
dotcms-1      | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[?:?]
dotcms-1      | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) ~[?:?]
dotcms-1      | 	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390) ~[?:?]
dotcms-1      | 	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[?:?]
dotcms-1      | 	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1732) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1295) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.Nio2Endpoint.setSocketOptions(Nio2Endpoint.java:339) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.Nio2Endpoint$Nio2Acceptor.completed(Nio2Endpoint.java:479) ~[?:?]
dotcms-1      | 	at org.apache.tomcat.util.net.Nio2Endpoint$Nio2Acceptor.completed(Nio2Endpoint.java:415) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.Invoker.invokeDirect(Invoker.java:160) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.Invoker.invoke(Invoker.java:188) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.UnixAsynchronousServerSocketChannelImpl.onEvent(UnixAsynchronousServerSocketChannelImpl.java:194) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:305) ~[?:?]
dotcms-1      | 	at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113) ~[?:?]
dotcms-1      | 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
dotcms-1      | 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
dotcms-1      | 	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
dotcms-1      | Caused by: com.dotcms.contenttype.business.UniqueFieldValueDuplicatedException: Failed to recalculate unique value has for field 'title' in Content Type '070cda7fcda1ecf9c481dc4232ecc89e': ERROR: null value in column "unique_key_val" of relation "unique_fields" violates not-null constraint
dotcms-1      |   Detail: Failing row contains (null, {"live": true, "variant": "DEFAULT", "fieldValue": "111", "langu...).{
dotcms-1      |   "SQL": ["UPDATE unique_fields\nSET unique_key_val = encode(sha256(\n    jsonb_extract_path_text(supporting_values, 'contentTypeId')::bytea || \n    jsonb_extract_path_text(supporting_values, 'fieldVariableName')::bytea || \n    jsonb_extract_path_text(supporting_values, 'languageId')::bytea || \n    jsonb_extract_path_text(supporting_values, 'fieldValue')::bytea\n     || jsonb_extract_path_text(supporting_values, 'siteId')::bytea \n), 'hex'), \nsupporting_values = jsonb_set(supporting_values, '{uniquePerSite}', 'true') \nWHERE supporting_values->>'contentTypeId' = ?\nAND supporting_values->>'fieldVariableName' = ?"],
dotcms-1      |   "maxRows": [-1],
dotcms-1      |   "offest": [0],
dotcms-1      |   "params": [
dotcms-1      |     "070cda7fcda1ecf9c481dc4232ecc89e",
dotcms-1      |     "title"
dotcms-1      |   ]
dotcms-1      | }
dotcms-1      | 	at com.dotcms.contenttype.business.uniquefields.extratable.DBUniqueFieldValidationStrategy.recalculate(DBUniqueFieldValidationStrategy.java:268) ~[?:?]
dotcms-1      | 	at com.dotcms.contenttype.business.uniquefields.extratable.DBUniqueFieldValidationStrategy$Proxy$_$$_WeldClientProxy.recalculate(Unknown Source) ~[?:?]
dotcms-1      | 	at com.dotcms.contenttype.business.FieldAPIImpl.save(FieldAPIImpl.java:686) ~[?:?]
dotcms-1      | 	... 101 more

Acceptance Criteria

The uniquePerSite variable must be able to be set without problem under the specified scenario.

The only way this will fail is when such a variable is updated from true to false, and there are Contentlets sharing the same unique value. This is expected, and will require the user to manually update the unique fields as required.

dotCMS Version

Latest from main

Proposed Objective

Core Features

Proposed Priority

Priority 2 - Important

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

No response

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

@jdotcms
Copy link
Contributor

jdotcms commented Jan 10, 2025

I can not reproduce this on the latest main, the recalculation when switching from and to uniquePerSite is working without any error

@jdotcms
Copy link
Contributor

jdotcms commented Jan 10, 2025

The issue is not longer valid, latest code is working as an expected, moving to done

@jdotcms jdotcms moved this from In Progress to Done in dotCMS - Product Planning Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants