Validation Message for Meta Keywords exceeding 400 characters not firing

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
Had an issue come to me yesterday where a category page couldn't be saved.  Basically, the user was trying to update their meta keywords on the seo tab and went beyond the 400 character limit.

Property: MetaKeywords Error: The field MetaKeywords must be a string or array type with a maximum length of '400' is the error thrown...however, the user gets the white "error screen" and they don't know what happened.

I look at this as a bug as the validator isn't firing properly.

Visual Studio dumps
[DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.]
   System.Data.Entity.Internal.InternalContext.SaveChanges() +182
   System.Data.Entity.Internal.LazyInternalContext.SaveChanges() +56
   System.Data.Entity.DbContext.SaveChanges() +52
   Nop.Data.EfRepository`1.Insert(T entity) in e:\Development\NopCommerce\Libraries\Nop.Data\EfRepository.cs:52

[Exception: Property: MetaKeywords Error: The field MetaKeywords must be a string or array type with a maximum length of '400'.
]
   Nop.Data.EfRepository`1.Insert(T entity) in e:\Development\NopCommerce\Libraries\Nop.Data\EfRepository.cs:64
   Nop.Services.Logging.DefaultLogger.InsertLog(LogLevel logLevel, String shortMessage, String fullMessage, Customer customer) in e:\Development\NopCommerce\Libraries\Nop.Services\Logging\DefaultLogger.cs:197
etc....
9 years ago
Hi Chuck,

Thanks a lot for reporting. I've just created a work item here.

Yes, this is a know issue. We can add validation rules to appropriate validator(s) in Nop.Admin but now just do not want to duplicate the code from the \Libraries\Nop.Data\Mapping\Catalog\ProductMap.cs file. Looking for a bettre solution.

P.S. There are a lot of other palces where it could happen.
P.P.S. Usually people have 100-255 chars maximum in this field
9 years ago
Thanks Andrei,

ok, this makes sense in terms of avoiding duplicating code.

In this case, it was a Google rep that recommended to the client to add several more keywords (which I also thought was excessive).

I think for now I will just add some text in the razor view for those seo tabs telling the user what the limit is under the text box.  This way they at least get some indication there is a limit until we can find a clean way to do validation without all the duplication.

Thanks again
Chuck
8 years ago
Problem solved. Details here GitHub: #21da3e1. Thanks for reporting.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.