Skip to content

Introduce new states for XML Validation #2804

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

josephsnyder
Copy link
Member

Change the name of the environment variable from VALIDATE_XML_SUBMISSIONS to VALIDATE_SUBMISSIONS
Change the handling of the XML validation in the environment to be a string setting instead of a boolean.

The new state should be as follows
No Value or "SILENT": Log a message in the CDash logs and attempt to parse XML
"WARN" : Log, return a message with a warning label in the
http response of the submission, and attempt to parse XML
"REJECT" : Log and return 400 to prevent further submissions and do not attempt
to process the XML

@williamjallen williamjallen added this to the v4.0 milestone Apr 15, 2025
@josephsnyder josephsnyder force-pushed the introdue_submission_validation_enum branch from 2d82def to b3e3841 Compare April 15, 2025 14:46
@josephsnyder josephsnyder force-pushed the introdue_submission_validation_enum branch from b3e3841 to 5e53cf4 Compare April 16, 2025 19:26
@josephsnyder josephsnyder force-pushed the introdue_submission_validation_enum branch 2 times, most recently from bd28661 to 43d3b75 Compare April 18, 2025 13:14
$this->failProcessing($filename, 400, "XML validation failed for $filename:" . PHP_EOL . $e->getMessage());
}
$message = $e->getMessage();
Log::info($message);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use report() here to include the stack trace in the log while reporting back a nicer error to the user.

Suggested change
Log::info($message);
report($e);

Comment on lines 164 to 166
$message = "XML validation failed: Found issues with file $filename:" . PHP_EOL . $error_string;
// We always log validation failures, but we only send messages back to the client if configured to do so
Log::warning("Submission validation failed for file '$filename':" . PHP_EOL);
if ((bool) config('cdash.validate_xml_submissions') === true) {
$this->failProcessing($filename, 400, "XML validation failed: rejected file $filename:" . PHP_EOL . $error_string);
Log::info($message);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging this entire message including all of the specific errors could result in very lengthy error messages in the logs. Additionally, I think we should avoid multi-line log messages in general unless there is a good rationale for it. Perhaps just report the "XML validation failed: Found issues with file $filename:" part in the logs and send the rest back to the user?

@josephsnyder josephsnyder force-pushed the introdue_submission_validation_enum branch 2 times, most recently from bf5439c to ffbb826 Compare April 21, 2025 17:32
Change the name of the environment variable from VALIDATE_XML_SUBMISSIONS
to VALIDATE_SUBMISSIONS
Change the handling of the XML validation in the environment to be a
string setting instead of a boolean.

The new state should be as follows
  No Value or "SILENT": Log a message in the CDash logs and attempt to parse XML
  "WARN"              : Log, return a message with a warning label in the
                        http response of the submission, and attempt to parse XML
  "REJECT"            : Log and return 400 to prevent further submissions and do not attempt
                        to process the XML
@josephsnyder josephsnyder force-pushed the introdue_submission_validation_enum branch from ffbb826 to e6ed50c Compare April 22, 2025 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants