Skip to content
Snippets Groups Projects

Add handling for bad data in ci_build options

Closed Jeremy Jackson requested to merge fix-ci-build-options-serialization into master
3 unresolved threads

What does this MR do?

There’s a scenario by which a stringified ruby hash is making it into options values, which can’t be serialized/deserialized properly but is currently not being handled. This fix resolves the scenarios we’re seeing where the data is invalid, but we should take steps to not allow that bad data into the system at all.

#34860 (closed) gitlab-com/gl-infra/production#1275 (closed)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

~backstage ~bug

Edited by Jeremy Jackson

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
3695 3695
3696 3696 it { is_expected.to be_falsey }
3697 3697 end
3698
3699 context 'when options is a string' do
3700 let(:options) { nil }
3701
3702 before do
3703 build.write_attribute(:options, %{{"artifacts"=>{"reports"=>{"junit"=>"junit.xml"}}}})
  • assigned to @sabrams and @stanhu

  • Author Contributor

    @stanhu, would you like to provide your thoughts on this? I think we can merge it and open an issue to revert this code once a fix / data cleanup process has been run.

  • Jeremy Jackson changed the description

    changed the description

  • Reviewer roulette

    Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.

    To spread load more evenly across eligible reviewers, Danger has randomly picked a candidate for each review slot. Feel free to override this selection if you think someone else would be better-suited, or the chosen person is unavailable.

    Once you've decided who will review this merge request, mention them as you normally would! Danger does not (yet?) automatically notify them for you.

    Category Reviewer Maintainer
    backend Felipe Artur (@felipe_artur) Sean McGivern (@smcgivern)

    Generated by :no_entry_sign: Danger

    Edited by 🤖 GitLab Bot 🤖
  • 767 767 true
    768 768 end
    769 769
    770 def options
    771 @options ||= begin
    772 return self[:options] if self[:options].is_a?(HashWithIndifferentAccess)
    773 # for really bad data handling scenarios, barely production ready
    774 HashWithIndifferentAccess.new(JSON.parse(self[:options].gsub('=>', ':'))) rescue { }
  • Jeremy Jackson added 1 commit

    added 1 commit

    • fa73f65d - Add handling for bad data in ci_build options

    Compare with previous version

  • 37 37 end
    38 38
    39 39 def options
    40 read_metadata_attribute(:options, :config_options, {})
    40 ret = read_metadata_attribute(:options, :config_options, {})
  • Please register or sign in to reply
    Loading