Skip to content

Fix join on string error in failure reporting

George Koltsov requested to merge fix-join-on-string-error-in-reporting into master

What does this MR do and why?

Fixes an error in failure reporting when the message_lines of a failure are only a string instead of an array. Usually happens with shared examples.

Error:

/builds/gitlab-org/gitlab/.gems/gems/gitlab-qa-8.10.1/lib/gitlab/qa/report/relate_failure_issue.rb:96:in `full_stacktrace': undefined method `join' for #<String:0x00007fc6bb691660> (NoMethodError)

Example json report failure for a shared example with a string in message_lines (we want to use the message instead):

  "exceptions": [
    {
      "class": "RSpec::Expectations::ExpectationNotMetError",
      "message": "expected to find text \"Please confirm your email address\" in \"Sign in to GitLab to connect your organization's account GitLab Enterprise Edition Username or email Password Remember me Forgot your password? Sign in By signing in you accept the Terms of Use and acknowledge the Privacy Policy and Cookie Policy. Don't have an account yet? Register now Explore Help About GitLab Community forum\"",
      "message_lines": "Shared Example Group: \"group membership actions\" called from ./qa/specs/features/ee/browser_ui/1_manage/group/group_saml_enforced_sso_new_account_spec.rb:98",
      ...

Example of regular json report failure (we want to use message_lines here but if it's an empty array, we use message):

  "exceptions": [
    {
      "class": "Capybara::ElementNotFound",
      "message": "Unable to find css \"[data-qa-selector=\\\"SAST_BANDIT_EXCLUDED_PATHS_field\\\"],.qa-SAST-BANDIT-EXCLUDED-PATHS-field\"",
      "message_lines": [
        "Failure/Error: config_form.fill_dynamic_field(test_data_string_array.first, test_data_string_array[1])",
        "",
        "Capybara::ElementNotFound:",
        "  Unable to find css \"[data-qa-selector=\\\"SAST_BANDIT_EXCLUDED_PATHS_field\\\"],.qa-SAST-BANDIT-EXCLUDED-PATHS-field\""
      ],
    ...

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by George Koltsov

Merge request reports