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

RHINENG-10827: unassign systems before template delete #1442

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

MichaelMraka
Copy link
Collaborator

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Copy link

jira-linking bot commented Jun 20, 2024

Referenced Jiras:
https://issues.redhat.com/browse/RHINENG-10827

@MichaelMraka MichaelMraka requested a review from psegedy June 20, 2024 10:05
@MichaelMraka MichaelMraka force-pushed the pr2 branch 2 times, most recently from 25573c9 to 2c2cb3f Compare June 20, 2024 13:40

// unassign systems from the template
err = database.DB.Model(&models.SystemPlatform{}).
Where("rh_account_id = ? AND template_id = ?", accountID, templateID).
Copy link
Member

@psegedy psegedy Jun 21, 2024

Choose a reason for hiding this comment

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

when the template is not found then I think it won't be error from the query above but templateID=0 would be added to this query. Could that be a problem? I hope not
or maybe it would be gorm.ErrRecordNotFound in which case it is correct

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added check for templateID == 0

Copy link
Member

@psegedy psegedy left a comment

Choose a reason for hiding this comment

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

it seems like error is always nil in this function if I didn't miss something so we might not need to return error at all, otherwise LGTM

@MichaelMraka
Copy link
Collaborator Author

it seems like error is always nil in this function if I didn't miss something so we might not need to return error at all, otherwise LGTM

Well, let's try once more... let TemplateDelete() return errors and put error handling into TemplatesMessageHandler(). This seems to be cleaner.

@MichaelMraka MichaelMraka merged commit e6fd838 into RedHatInsights:master Jun 24, 2024
3 of 4 checks passed
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.

2 participants