Skip to content

Use normalized license data in csv export

What does this MR do and why?

Part of https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/3818

When exporting a license's usage data to csv, the file included the stored data from the database. For some licenses, this led to the license key to contain carriage returns (see more info in this comment) that made the file unreadable with CSV.read.

This change will use the normalized data that removes any carriage returns from the license data.`

How to set up and validate locally

General:

  1. In CustomersDot, create a new offline license in the admin area.
  2. Upload the newly created license to your GitLab instance.

Without this change:

  1. Go to /admin/subscription.
  2. Download the license usage file by clicking the "Export license usage data" button.
  3. In a rails console read the downloaded file with CSV.read(<path_to_file>).
  4. This should raise an error like this one:
    CSV::MalformedCSVError: Any value after quoted field isn't allowed in line 1.

With this change:

  1. Go to /admin/subscription.
  2. Download the license usage file by clicking the "Export license usage data" button.
  3. In a rails console read the downloaded file with CSV.read(<path_to_file>).
  4. The file should be readable and not raise an error.

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 Corinna Gogolok

Merge request reports