Skip to content

Issue 6736 - Exception thrown by dsconf instance repl get_ruv - #6742

Merged
progier389 merged 2 commits into
389ds:mainfrom
progier389:i6736
Apr 16, 2025
Merged

progier389 merged 2 commits into
389ds:mainfrom
progier389:i6736

Conversation

@progier389

@progier389 progier389 commented Apr 10, 2025 •

Copy link
Copy Markdown
Contributor

After issue #6715 commit dsconf instance replication get_ruv fails with error
because by default NormalizedRidDict does not calling getitem as I expected.
The solution is to overwrite the get function to do things properly.

Issue: #6736
Relates: #6715

Reviewed by: @droideck (Thanks!)

@progier389

Copy link
Copy Markdown
Contributor Author

test_ruv_url_not_added_if_different_uuid is still failing! 😞

@progier389

Copy link
Copy Markdown
Contributor Author

Ok. the problem is that None is expected when there is no default rather than KeyError ...

Comment on lines +844 to +849
def get(self, key, vdef=None):
try:
return self[key]
except KeyError:
return vdef

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have a concern that now .get() and .__getitem__() have different behaviour. One raises a KeyError, and another one returns None/vdef.

Personally, I'd change get() to (and then, adapt the usage everywhere it's needed):

    nkey = NormalizedRidDict.normalize_rid(key)
    return super().get(nkey, vdef)

But I don't have a hard opinion here. We can go either way for NormalizedRidDict.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This behavior difference also exists when using plain dict.
I agree that it is a bit confusing as I blindly fall into that pitfall ! 😉
But that is the way python implemented dict:

[src]$cat dict.py 
d = { 'a':'b' }
print( d.get('k') )
try:
    print( d['k'] )
except KeyError:
    print("d['k'] raised KeyError")
try:
    print( d.__getitem__('k') )
except KeyError:
    print("d.__getitem__('k') raised KeyError")
[src]$python3 dict.py 
None
d['k'] raised KeyError
d.__getitem__('k') raised KeyError
[src]$

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay, never mind...
Looks like it's by design! Oh, well

@droideck droideck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@progier389
progier389 merged commit 64b2514 into 389ds:main Apr 16, 2025
abeisemb pushed a commit to abeisemb/389-ds-base that referenced this pull request Apr 17, 2025
…6742)

After issue 389ds#6715 commit dsconf instance replication get_ruv fails with error
because by default NormalizedRidDict does not calling getitem as I expected.
The solution is to overwrite the get function to do things properly.

Issue: 389ds#6736
Relates: 389ds#6715

Reviewed by: @droideck (Thanks!)
@progier389
progier389 deleted the i6736 branch May 20, 2025 13:06
progier389 added a commit that referenced this pull request Jun 23, 2025
After issue #6715 commit dsconf instance replication get_ruv fails with error
because by default NormalizedRidDict does not calling getitem as I expected.
The solution is to overwrite the get function to do things properly.

Issue: #6736
Relates: #6715

Reviewed by: @droideck (Thanks!)

(cherry picked from commit 64b2514)
progier389 added a commit that referenced this pull request Jun 23, 2025
After issue #6715 commit dsconf instance replication get_ruv fails with error
because by default NormalizedRidDict does not calling getitem as I expected.
The solution is to overwrite the get function to do things properly.

Issue: #6736
Relates: #6715

Reviewed by: @droideck (Thanks!)

(cherry picked from commit 64b2514)
progier389 added a commit that referenced this pull request Jun 23, 2025
After issue #6715 commit dsconf instance replication get_ruv fails with error
because by default NormalizedRidDict does not calling getitem as I expected.
The solution is to overwrite the get function to do things properly.

Issue: #6736
Relates: #6715

Reviewed by: @droideck (Thanks!)

(cherry picked from commit 64b2514)
progier389 added a commit that referenced this pull request Jun 23, 2025
After issue #6715 commit dsconf instance replication get_ruv fails with error
because by default NormalizedRidDict does not calling getitem as I expected.
The solution is to overwrite the get function to do things properly.

Issue: #6736
Relates: #6715

Reviewed by: @droideck (Thanks!)

(cherry picked from commit 64b2514)
progier389 added a commit that referenced this pull request Jun 23, 2025
After issue #6715 commit dsconf instance replication get_ruv fails with error
because by default NormalizedRidDict does not calling getitem as I expected.
The solution is to overwrite the get function to do things properly.

Issue: #6736
Relates: #6715

Reviewed by: @droideck (Thanks!)

(cherry picked from commit 64b2514)
progier389 added a commit that referenced this pull request Jun 23, 2025
After issue #6715 commit dsconf instance replication get_ruv fails with error
because by default NormalizedRidDict does not calling getitem as I expected.
The solution is to overwrite the get function to do things properly.

Issue: #6736
Relates: #6715

Reviewed by: @droideck (Thanks!)

(cherry picked from commit 64b2514)
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