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

db, test: do not create nick ID by default #2234

Merged
merged 2 commits into from
Jan 9, 2022
Merged

Conversation

dgw
Copy link
Member

@dgw dgw commented Jan 6, 2022

Having get_nick_id() default to create=True may cause unexpected behavior if invalid nicknames are passed to it via plugins' use of the getter and setter methods.

We are taking this opportunity to fix the API design itself, with no period of deprecation and warnings, since this particular method is mostly used only by the database object itself, and isn't really intended for direct use by plugins.

I've also added some more assertions and error-case checking to some of the related tests for sopel.db. The tests required minimal changes to continue passing; only cases where some manual setup was using get_nick_id() as a shortcut to make sure the nick would exist in the database before running the test case needed to be changed.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches

Notes

A code search on GitHub for get_nick_id returned very few results that weren't either a Sopel plugin or a clone of Sopel itself being used as the base for a custom bot. Of the results that were actually plugin code, only one out of a dozen or so might be problematic (and I will open an issue on that repo to let the author know about this planned change).

As I thought, not many people actually use this function directly. At least half the plugin results were from my plugins or modified clones thereof (which already used create=False explicitly).

Having `get_nick_id()` default to `create=True` may cause unexpected
behavior if invalid nicknames are passed to it via plugins' use of the
getter and setter methods.

We are taking this opportunity to fix the API design itself, with no
period of deprecation and warnings, since this particular method is
mostly used only by the database object itself, and isn't really
intended for direct use by plugins.

I've also added some more assertions and error-case checking to some of
the related tests for `sopel.db`.
@dgw dgw added Tweak Breaking Change Stuff that probably should be mentioned in a migration guide labels Jan 6, 2022
@dgw dgw added this to the 8.0.0 milestone Jan 6, 2022
@dgw dgw requested a review from a team January 6, 2022 21:40
@dgw
Copy link
Member Author

dgw commented Jan 6, 2022

This CI failure is what you were talking about in #2227, eh, @Exirel?

@Exirel
Copy link
Contributor

Exirel commented Jan 6, 2022

This CI failure is what you were talking about in #2227, eh, @Exirel?

Yes. I'm trying to fix it, it's almost done.

@dgw dgw force-pushed the no-get_nick_id-create branch from fdb901c to 7d0c5a9 Compare January 8, 2022 20:09
@Exirel
Copy link
Contributor

Exirel commented Jan 8, 2022

Oh, this will conflict with #2231 a lot. 😁

@dgw
Copy link
Member Author

dgw commented Jan 8, 2022

Oh, this will conflict with #2231 a lot. 😁

Heh, #2231 already has conflicts from merging #2233, so what's a little more? 😏 (And it looks to me like most of the conflict will come from type-hinting, not the actual changes to support "smart" identifiers, so really you did it to yourself. 😛)

@dgw dgw merged commit c37f62b into master Jan 9, 2022
@dgw dgw deleted the no-get_nick_id-create branch January 9, 2022 21:25
@dgw
Copy link
Member Author

dgw commented Jan 9, 2022

Figured if I merge sooner, you can assess + fix the conflicts sooner. 😸

@Exirel
Copy link
Contributor

Exirel commented Jan 9, 2022

Is that a permission to rebase right now? 😁

@dgw
Copy link
Member Author

dgw commented Jan 9, 2022

"As they say in the Temporal Mechanics department, 'There's no time like the present.'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Stuff that probably should be mentioned in a migration guide Tweak
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants