Skip to content

Conversation

@brianhelba
Copy link
Collaborator

@brianhelba brianhelba commented Oct 8, 2025

Fixes #1896

r'versions',
VersionViewSet,
basename='version',
basename='dandiset-version',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DRF 3.15 changes:

Raise ImproperlyConfigured exception if basename is not unique [#8438]

I think this is a sensible new name, since the viewsets are nested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason for this change was that NestedAssetViewSet and AssetViewSet basenames were conflicting. I updated VersionViewSet also, just for consistency.

Comment on lines -82 to +94
assert resp.json() == ['Zarr already exists']
assert resp.json() == {
'non_field_errors': ['The fields dandiset, name must make a unique set.']
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the new error raised by the serializer?

@brianhelba brianhelba force-pushed the dep-upgrade branch 5 times, most recently from f7a53c7 to f8e357e Compare October 10, 2025 02:03
@brianhelba brianhelba force-pushed the drf-upgrade branch 2 times, most recently from 2ba0dd2 to 046381b Compare October 10, 2025 02:26
@mvandenburgh mvandenburgh force-pushed the dep-upgrade branch 3 times, most recently from 2b817d8 to bdf6846 Compare October 14, 2025 16:24
Base automatically changed from dep-upgrade to master October 14, 2025 18:20
@brianhelba brianhelba marked this pull request as ready for review October 14, 2025 18:24
@mvandenburgh mvandenburgh self-requested a review October 14, 2025 18:42
Also rename the `VersionViewSet` for consistency.
The latest DRF now enforces uniqueness constraints in serializer validation,
so all other validation should happen at the same time to avoid incorrect
error codes being returned.
Comment on lines +57 to +59
return int(data)
except (ValueError, TypeError):
self.fail('invalid')
Copy link
Member

Choose a reason for hiding this comment

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

As it stands, this validation will miss negative numbers, as well as numbers greater than 6 digits.

Suggested change
return int(data)
except (ValueError, TypeError):
self.fail('invalid')
data = int(data)
except (ValueError, TypeError):
self.fail('invalid')
if isinstance(data, int) and (data < 1 or data > 999_999): # noqa: PLR2004
self.fail('invalid')

Comment on lines +62 to +65
# If this was loaded via ".get_serializer", then the request is available in context
self.user: User | AnonymousUser | None = (
self._context['request'].user if 'request' in self._context else None
)
Copy link
Member

Choose a reason for hiding this comment

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

I guess the assumption here is that if self._context['request'] is not available, this must be called by internal code, and we're okay with keeping the dandiset queryset as Dandiset.objects.all()?

Comment on lines +54 to +57
dandiset = serializers.PrimaryKeyRelatedField(
queryset=Dandiset.objects.all(),
pk_field=DandisetIdentifierField(),
)
Copy link
Member

Choose a reason for hiding this comment

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

Does this automatically raise an exception if the specified dandiset ID is not found? And if so, what's the response code (seems like it might be 400 instead of 404)?

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.

DRF 3.15.0 is incompatible

3 participants