Skip to content
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

Don't recreate the same channel due to https errors. Closes #1348 #1355

Merged

Conversation

yachtcaptain23
Copy link
Contributor

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Tagged reviewers.
  • Integrated piwik/matomo (for code that adds new buttons).
  • Addressed or ignored all brakeman warnings

Test Plan:

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions

Security:

@nvonpentz
Copy link
Collaborator

Not sure if this is completed yet, but I'm still able to reproduce brave-intl/creators-private-issues#845 on this branch

@corymcdonald
Copy link
Contributor

corymcdonald commented Nov 16, 2018

I was investigating what to do in that case because really what happens is that the domain normalizer strips everything and goes to username.github.io which calls the fetch call to return 404.

So we'd need to write some code to handle that in this method
https://github.com/brave-intl/publishers/blob/staging/app/services/site_channel_host_inspector.rb#L46

EDIT: Whoops, I was thinking of a different issue 😅

@yachtcaptain23 yachtcaptain23 changed the title Don't recreate the same channel due to https errors. Closes #1348 [WIP] Don't recreate the same channel due to https errors. Closes #1348 Nov 16, 2018
@yachtcaptain23
Copy link
Contributor Author

Spoke with Nick

Action items:
(1) Get rid of the abandoned scope on SiteChannelDetails
(2) Update the code in app/jobs/clean_abandoned_site_channels_job.rb
(3) Re-insert back original controller logic.

@yachtcaptain23 yachtcaptain23 changed the title [WIP] Don't recreate the same channel due to https errors. Closes #1348 Don't recreate the same channel due to https errors. Closes #1348 Nov 20, 2018

details.channel.destroy
channels.joins(:site_channel_details).each do |channel|
raise unless channel.details.verification_method.nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

can we change this to
raise if channel.details.verification_method.present?
i think that's slightly more readable

@corymcdonald
Copy link
Contributor

Hey Albert, I don't think this actually resolves the issue, here's a gif to reproduce it
nov-21-2018 11-07-05

@yachtcaptain23
Copy link
Contributor Author

@corymcdonald I agree that this solution doesn't explain the whole story. The issue's wording should be restructured, as the issue you're seeing might not be an issue, and I thought it had tied into another issue in Sentry. I think we should continue to allow users to make channels that haven't fulfilled the flow (it's a tradeoff between refactoring a bunch of logic and inheriting more risk or maintain a confusing mental model of visible and non-visible/abandoned channels 😞 )

I originally intended to solve https://sentry.io/brave-software/publishers-production-t2/issues/761612367/?query=is:unresolved and brave-intl/creators-private-issues#845 in this PR. However, they seem to be separate problems: the sentry error was 1 simple bad channel in which I fixed. This PR solves some weird state called abandoned when it should have just been non-visible

To elaborate further on the Sentry error: We have this constraint that prevents a publisher from creating duplicates (and somehow, someone got around it. I don't think it's a race condition though):

  def site_channel_details_brave_publisher_id_unique_for_publisher
    duplicate_unverified_channels = publisher.channels.visible_site_channels
                                                     .where(site_channel_details: { brave_publisher_id: self.details.brave_publisher_id })
                                                     .where.not(id: id)

    if duplicate_unverified_channels.any?
      errors.add(:brave_publisher_id, "must be unique")
    end
  end

Anyways, an elegant solution to solve brave-intl/creators-private-issues#845 for a dropped funnel, is to allow the user to continue from where they left off. However, there's several channels that are abandoned and not meant to be visible. Overall the state transitions for adding a channel are confusing, but they haven't caused any major issues, yet (except for us developers).

@nvonpentz
Copy link
Collaborator

should be resolved now, the verification method wasn't being set which is needed to make a channel visible

@yachtcaptain23 yachtcaptain23 merged commit dc05d38 into brave-intl:staging Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants