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

Scrub args from keywords before initializing. #321

Merged
merged 1 commit into from
Feb 19, 2015

Conversation

ralphbean
Copy link
Contributor

This is wild.

The symptom you'd get is this: The first time
fedmsg.publish(topic=topic, msg=dict(...)) is ever called, fedmsg
isn't initialized yet. Those topic and msg arguments are passed through
to init(**kw) as extra keyword arguments and so "topic" and "msg"
appear in the global config dict (internally).

This never mattered in practice. They were there, and noone cared.

I'm hitting it now because in fmn, we try to call
fedmsg.meta.msg2link(msg=msg, **config) but there is a msg key
in config from the first time publish was called and so it fails
with "cannot have two keyword arguments named 'msg'".

This is wild.

The symptom you'd get is this:  The *first* time
``fedmsg.publish(topic=topic, msg=dict(...))`` is ever called, fedmsg
isn't initialized yet.  Those topic and msg arguments are passed through
to ``init(**kw)`` as extra keyword arguments and so "topic" and "msg"
appear in the global config dict (internally).

This never mattered in practice.  They were there, and noone cared.

I'm hitting it now because in fmn, we try to call
``fedmsg.meta.msg2link(msg=msg, **config)`` but there is a ``msg`` key
in config from the first time ``publish`` was called and so it fails
with "cannot have two keyword arguments named 'msg'".

for arg in scrub:
if arg in kw:
del kw[arg]
Copy link
Member

Choose a reason for hiding this comment

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

Would we want to log which arg are dropped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh, I don't think logger isn't set up at this point. It would need its config which hasn't been loaded yet.

@pypingou
Copy link
Member

After some discussions and thoughts on IRC, 👍 for me

ralphbean added a commit that referenced this pull request Feb 19, 2015
Scrub args from keywords before initializing.
@ralphbean ralphbean merged commit 0621234 into develop Feb 19, 2015
@ralphbean ralphbean deleted the feature/scrub-api-args branch February 19, 2015 19:27
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