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

Merged
merged 1 commit into from
Apr 23, 2025

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 4 times, most recently from e6ed50c to 603448f Compare April 23, 2025 14:42
Copy link
Collaborator

@williamjallen williamjallen left a comment

Choose a reason for hiding this comment

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

A couple minor nitpicks as described below, and then I think this should be good to go.

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 603448f to e2c8de2 Compare April 23, 2025 17:02
@williamjallen williamjallen enabled auto-merge April 23, 2025 17:23
@williamjallen williamjallen added this pull request to the merge queue Apr 23, 2025
Merged via the queue into master with commit 7a6a61a Apr 23, 2025
7 checks passed
@williamjallen williamjallen deleted the introdue_submission_validation_enum branch April 23, 2025 18:21
github-merge-queue bot pushed a commit that referenced this pull request May 12, 2025
The "email administrator" project setting has gradually become obsolete,
now only used to report submissions which cannot be parsed. This is no
longer necessary in light of our [recent
effort](#2804) to rethink the
submission validation process. This PR removes the setting and all
related logic.
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