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

Page validation error #1160

Closed
dukeofsussex opened this issue Oct 14, 2016 · 1 comment · Fixed by #1163
Closed

Page validation error #1160

dukeofsussex opened this issue Oct 14, 2016 · 1 comment · Fixed by #1163
Assignees
Labels

Comments

@dukeofsussex
Copy link
Contributor

Description:
Trying to create an exact duplicate of a page results in an error.

Steps to Reproduce:

  • Create some random page
  • Create a new page with the same name as the previously created one and fill in required fields
  • Save
  • Receive no success or error message in the admin panel, instead the log output below

This also seems to happen if the URL is already taken.

Configuration Details:
Default config, no plugins

Log Output:

2016-10-14T10:33:12.283Z - error: [M] RequestHandler: RangeError: Invalid status code: 11000
    at ServerResponse.writeHead (_http_server.js:192:11)
    at RequestHandlerModule.RequestHandler.writeResponse (E:\GitHub\newsletter\include\http\request_handler.js:1334:23)
    at RequestHandlerModule.RequestHandler.onRenderComplete (E:\GitHub\newsletter\include\http\request_handler.js:1274:18)
    at E:\GitHub\newsletter\include\http\request_handler.js:805:22
    at E:\GitHub\newsletter\include\error\formatters\error_formatters.js:294:13
    at ErrorFormatters.json (E:\GitHub\newsletter\include\error\formatters\error_formatters.js:98:9)
    at Function.ErrorFormatters.formatForMime (E:\GitHub\newsletter\include\error\formatters\error_formatters.js:293:9)
    at E:\GitHub\newsletter\include\http\request_handler.js:794:32
    at getActiveTheme (E:\GitHub\newsletter\include\http\request_handler.js:767:24)
    at RequestHandlerModule.RequestHandler.serveError (E:\GitHub\newsletter\include\http\request_handler.js:778:9)

PencilBlue Version: 0.7.0

Node.js Version: 4.4.5

Environment Description: Win Dev

@brianhyder brianhyder added the bug label Oct 14, 2016
@brianhyder brianhyder added this to the 0.7.1 - Bug fixes milestone Oct 14, 2016
@brianhyder brianhyder self-assigned this Oct 14, 2016
@brianhyder
Copy link
Member

NOTES:

  • There is a unique index on headline for pages. Need to check on articles.
  • The 11000 error is thrown because the mongo error objects use a code property off of the error, just like PB, to use for setting the HTTP status. This causes conflict when the DB constraints aren't handled and prevented by the service layer and its validations.
  • This most likely applies to articles because both Articles and Pages have similar validation functions.

The Fix:

  • double check on article and see if the validation is needed for it too.
  • Add a headline validation routine to ContentObjectService since both ArticleService and PageService extend it. Keep things DRY.
  • The validation function should verify that only a single piece of content of the specified type has that headline. This can be done using the DAO.unique function.
  • Call the validation function from the validation routine in each service (assuming applicable to both articles and pages).

brianhyder added a commit that referenced this issue Oct 18, 2016
brianhyder added a commit that referenced this issue Oct 18, 2016
#1160 #1161 Adds validation to prevent articles and pages with duplic…
dukeofsussex pushed a commit to dukeofsussex/pencilblue that referenced this issue Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants