It's all about the answers!

Ask a question

PropertyConstraintException for 'scm create changeset'


Daniel Junglas (2144) | asked Mar 28 '12, 11:40 a.m.
retagged Dec 10 '12, 3:21 a.m. by Martin Dam Pedersen (1352814)
When trying to create a changeset using the command line interface (scm) I got


com.ibm.team.repository.common.validation.PropertyConstraintException: Validation errors for item: type = ChangeSet, itemId = [UUID ...]
at com.ibm.team.scm.common.internal.util.ValidationUtils.checkPropertyConstraints(ValidationUtils.java:33)
at com.ibm.team.scm.service.internal.operations.CreateChangeSetOperation.run(CreateChangeSetOperation.java:70)
at com.ibm.team.scm.service.internal.ScmService$16.run(ScmService.java:794)
at com.ibm.team.scm.service.internal.AbstractScmService$3.run(AbstractScmService.java:574)
...


The comment for the changeset is auto-generated and long (1033 lines, 44538 characters). Could that be the reason for the exception? I have seen this exception several times and always long comments were involved. For short comments I have not seen the exception yet. Is there a limit to the length of change set comments? I could not find a documented limit so far, but I might have looked in the wrong places.

Thanks,

Daniel

3 answers



permanent link
David Lafreniere (4.8k7) | answered Apr 05 '12, 11:44 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Well, I suppose that Java code won't really help for the command line, but at least I can confirm that would be why you can't save a change set.

But here's a non-internal way on how to truncate it yourself the Java way:


...
String shorterComment = truncate(IChangeSet.ITEM_TYPE, IChangeSet.COMMENT_PROPERTY, longComment);


public static String truncate(IType type, String propertyName, String value) {
if (value == null)
return value;
IStatus status= IItemValidator.INSTANCE.validateAttribute(type, propertyName, value);
if (status instanceof IStringSizeConstraintErrorStatus) {
long maxSize= ((IStringSizeConstraintErrorStatus) status).getMaxSize();
//max size is in number of bytes and substring is in number of characters.
//First do a rough truncation so truncate to maxBytes. i.e. #chars >= #bytes >= maxSize.
String truncated= value.substring(0, (int) Math.min(value.length(), maxSize));
//Here, #chars may be <maxSize> maxSize.
//incrementally cut down the length of the string until #bytes <maxSize> 0 && status instanceof IStringSizeConstraintErrorStatus);

return truncated;
}
return value;
}

private static String endAtWordBoundary(String string) {
int space= string.lastIndexOf(' ');
if (space > 0)
return string.substring(0, space);
if (string.length() > 1)
return string.substring(0, string.length() - 1);
return "";
}

permanent link
David Lafreniere (4.8k7) | answered Apr 05 '12, 11:19 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
...The comment for the changeset is auto-generated and long (1033 lines, 44538 characters).
...
Thanks,

Daniel


Yes, that is the issue. I don't recall offhand what the max byte size is for the change set comment property, but you can use this helper method to provide you with the longest possible comment that is valid (it will only truncate if it needs to)

String shorterComment = com.ibm.team.scm.common.internal.util.ValidationUtils.truncate(IChangeSet.ITEM_TYPE, IChangeSet.COMMENT_PROPERTY, longComment);

permanent link
Daniel Junglas (2144) | answered Apr 10 '12, 1:41 p.m.
Thanks a lot! That was very helpful. I used your code snippet to figure out that the maximum length for a comment on my RTC instance is 32768 characters. I can now use this limit to trim my comments for the command line interface.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.