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

core does not validate that playergroups sql table contains valid jobs/gangs #526

Closed
solareon opened this issue Aug 2, 2024 · 7 comments · Fixed by #527
Closed

core does not validate that playergroups sql table contains valid jobs/gangs #526

solareon opened this issue Aug 2, 2024 · 7 comments · Fixed by #527
Labels
bug Something isn't working need repro This bug report needs confirmation

Comments

@solareon
Copy link
Contributor

solareon commented Aug 2, 2024

Summary

playergroups not validated before being added to playerdata

Reproduction

Add gang/job to shared luas. Add gang/job to player via /addjob or /addgang. Remove gang/job from shared lua. The gang/job remains present in the PlayerData.jobs table.

Expected behavior

Invalid jobs/gangs are removed from the PlayerData.jobs table either on server startup or player load and an error message is thrown to advise the user to remove this bad data from the sql table

Actual behavior

gang/job remains present in the PlayerData.jobs table.

Additional context

No response

Current Version

v1.17.2

Custom Resources

any multijob utilizing core exports.

@solareon solareon added bug Something isn't working need repro This bug report needs confirmation labels Aug 2, 2024
@qbox-duck qbox-duck bot added this to Issues Aug 2, 2024
@github-project-automation github-project-automation bot moved this to Todo in Issues Aug 2, 2024
@Manason
Copy link
Contributor

Manason commented Aug 2, 2024

The solution should be done on player load and should remove using the exports, which will also take care of updating the database. No warning needed.

@Manason
Copy link
Contributor

Manason commented Aug 2, 2024

Although because jobs and gangs can be added at runtime, there is some risk of deleting player data just because a dependent script couldn't properly start. So there's also an argument not to modify the database.

@solareon
Copy link
Contributor Author

solareon commented Aug 2, 2024

Although because jobs and gangs can be added at runtime, there is some risk of deleting player data just because a dependent script couldn't properly start. So there's also an argument not to modify the database.

Was going to say just randomly nuking a players db table cause of something being busted in the lua might be a bit harsh. I think warning the user on the console and then not loading those jobs into the PlayerData.jobs would be probably the best compromise between not breaking too much stuff and not punishing a user for mistakes

@Manason
Copy link
Contributor

Manason commented Aug 2, 2024

Although because jobs and gangs can be added at runtime, there is some risk of deleting player data just because a dependent script couldn't properly start. So there's also an argument not to modify the database.

Was going to say just randomly nuking a players db table cause of something being busted in the lua might be a bit harsh. I think warning the user on the console and then not loading those jobs into the PlayerData.jobs would be probably the best compromise between not breaking too much stuff and not punishing a user for mistakes

I agree

@Manason
Copy link
Contributor

Manason commented Aug 3, 2024

On second thought @solareon The more common use case would be removing jobs/gangs, so shouldn't we optimize for that to reduce overall manual effort? I.e. it would be easier to recover from a mistake if accidentally deleting database stuff, versus require players to manually delete database stuff whenever they remove a job/gang

@solareon
Copy link
Contributor Author

solareon commented Aug 3, 2024

On second thought @solareon The more common use case would be removing jobs/gangs, so shouldn't we optimize for that to reduce overall manual effort? I.e. it would be easier to recover from a mistake if accidentally deleting database stuff, versus require players to manually delete database stuff whenever they remove a job/gang

So I think we can add another command similar to convertjobs where we clean the playergroups table when ran. This way if a user has old jobs they wish to remove we can do it cleanly for them while also allowing for mistakes

@Manason

@solareon
Copy link
Contributor Author

solareon commented Aug 3, 2024

PR submitted that should address all these issues

@github-project-automation github-project-automation bot moved this from Todo to Done in Issues Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need repro This bug report needs confirmation
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants