Bug 1416824

Summary: Candlepin refuses to register a consumer with a fact longer than 255 characters
Product: [Community] Candlepin Reporter: Barnaby Court <bcourt>
Component: candlepinAssignee: Chris "Ceiu" Rog <crog>
Status: CLOSED CURRENTRELEASE QA Contact: Katello QA List <katello-qa-list>
Severity: high Docs Contact:
Priority: high    
Version: 0.9.54CC: candlepin-bugs, katello-qa-list, khowell, redakkan, sengork, skallesh, vrjain
Target Milestone: ---Keywords: Triaged
Target Release: 0.9.54   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: candlepin-0.9.54.19-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1416823
: 1416825 (view as bug list) Environment:
Last Closed: 2017-02-07 17:38:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1416823    
Bug Blocks: 1416825    

Description Barnaby Court 2017-01-26 14:40:05 UTC
+++ This bug was initially created as a clone of Bug #1416823 +++

Description of problem:
Error when updating a consumer that had guest ids & a consumer fact longer than 255 characters. 

It appears that the flush caused the updated consumer object to be written to the database before the facts could be properly updated for the 255 character limit. The manipulation to the facts (keys & values) should be happening during the conversion to object form from the incoming json. 

candlepin-0.9.49.19-1.el7.noarch        
 
2017-01-04 14:55:25,582 [req=34e428eb-fbd0-415e-886b-095d34ece66b, org=XXX] ERROR org.candlepin.common.exceptions.mappers.CandlepinExceptionMapper - Runtime Error ERROR: value too long for type character varying(255) at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse:2,157
org.postgresql.util.PSQLException: ERROR: value too long for type character varying(255)
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157) ~[postgresql-jdbc.jar:na]
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886) ~[postgresql-jdbc.jar:na]
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255) ~[postgresql-jdbc.jar:na]
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555) ~[postgresql-jdbc.jar:na]
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417) ~[postgresql-jdbc.jar:na]
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363) ~[postgresql-jdbc.jar:na]
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:447) ~[c3p0-0.9.1.2.jar:0.9.1.2]
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:133) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:58) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1256) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.action.internal.CollectionRecreateAction.execute(CollectionRecreateAction.java:58) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:393) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:385) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:307) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:339) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1240) ~[hibernate-core-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:996) ~[hibernate-entitymanager-4.2.7.SP2-redhat-1.jar:4.2.7.SP2-redhat-1]
        at org.candlepin.model.AbstractHibernateCurator.flush(AbstractHibernateCurator.java:364) ~[AbstractHibernateCurator.class:na]
        at org.candlepin.controller.CandlepinPoolManager.revokeEntitlements(CandlepinPoolManager.java:1261) ~[CandlepinPoolManager.class:na]
        at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:58) ~[guice-persist-3.0-redhat-1.jar:3.0-redhat-1]
        at org.candlepin.controller.CandlepinPoolManager.revokeEntitlement(CandlepinPoolManager.java:1358) ~[CandlepinPoolManager.class:na]
        at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:58) ~[guice-persist-3.0-redhat-1.jar:3.0-redhat-1]
        at org.candlepin.resource.ConsumerResource.revokeGuestEntitlementsNotMatchingHost(ConsumerResource.java:1169) ~[ConsumerResource.class:na]
        at org.candlepin.guice.TransactionalInvoker.invoke(TransactionalInvoker.java:34) ~[TransactionalInvoker.class:na]
        at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:58) ~[guice-persist-3.0-redhat-1.jar:3.0-redhat-1]
        at org.candlepin.guice.CandlepinResourceTxnInterceptor.invoke(CandlepinResourceTxnInterceptor.java:33) ~[CandlepinResourceTxnInterceptor.class:na]
        at org.candlepin.resource.ConsumerResource.checkForGuestsUpdate(ConsumerResource.java:1096) ~[ConsumerResource.class:na]
        at org.candlepin.resource.ConsumerResource.performConsumerUpdates(ConsumerResource.java:855) ~[ConsumerResource.class:na]
        at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:58) ~[guice-persist-3.0-redhat-1.jar:3.0-redhat-1]
        at org.candlepin.resource.ConsumerResource.updateConsumer(ConsumerResource.java:818) ~[ConsumerResource.class:na]

Comment 1 Chris "Ceiu" Rog 2017-02-01 14:51:48 UTC
commit a9fab09a36575727aeedf80a5d8e611f5db88943
Author: Chris Rog <crog>
Date:   Wed Jan 25 17:16:59 2017 -0500

    1416825: Abstracted out property validation to new validator framework
    
    - Added the new PropertyValidator class and its subclasses
      AttributeValidator and FactValidator, which provide implementations
      for validating attributes and facts, respectively
    - Updated the ProductCurator and ConsumerCurator to use the new
      PropertyValidator instances in place of their old private validation
      methods
    - ConsumerValidator no longer massages inbound fact data, but will
      now, instead, throw PropertyValidationExceptions when it encounters
      malformed or otherwise unmanagable data
    - ConsumerResource now provides the massaging and filtering
      functionality previously performed in the ConsumerCurator