Page MenuHomeSoftware Heritage
Feed Advanced Search

Sep 9 2022

jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.

Here is a way to do it:

diff --git a/swh/graphql/resolvers/resolvers.py b/swh/graphql/resolvers/resolvers.py
index 60992bb..1b0e93f 100644
--- a/swh/graphql/resolvers/resolvers.py
+++ b/swh/graphql/resolvers/resolvers.py
@@ -93,6 +93,8 @@ def snapshot_resolver(
 def visit_snapshot_resolver(
     obj, info: GraphQLResolveInfo, **kw
 ) -> rs.snapshot.VisitSnapshotNode:
+    if obj.snapshotSWHID is None:
+        return None
     resolver = get_node_resolver("visit-snapshot")
     return resolver(obj, info, **kw)
 
diff --git a/swh/graphql/tests/functional/test_visit_status.py b/swh/graphql/tests/functional/test_visit_status.py
index a250a9a..d83861a 100644
--- a/swh/graphql/tests/functional/test_visit_status.py
+++ b/swh/graphql/tests/functional/test_visit_status.py
@@ -28,7 +28,7 @@ def test_get_visit_status(client):
         visit.origin,
         visit.visit,
     )
-    data, _ = get_query_response(client, query_str)
+    data, err = get_query_response(client, query_str)
     result_status = get_visit_status()[3]
     assert data["visit"]["status"]["nodes"][0] == {
         "date": result_status.date.isoformat(),
@@ -36,6 +36,7 @@ def test_get_visit_status(client):
         "status": result_status.status,
         "type": result_status.type,
     }
+    assert err is None
 
 
 def test_get_visit_missing_snapshot(client):
@@ -67,7 +68,4 @@ def test_get_visit_missing_snapshot(client):
         "status": result_status.status,
         "type": result_status.type,
     }
-    assert len(err) == 1
-    assert (
-        "Cannot return null for non-nullable field Snapshot.swhid" in err[0]["message"]
-    )
+    assert err is None
Sep 9 2022, 5:04 PM
jayeshv updated the diff for D8426: Return none for missing snapshot in a visit status.

update error to raise

Sep 9 2022, 3:52 PM
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.

Sure, but in that example, the error is because for some reason, they could not get the value of name for an object that exists. The error in the example even reflects this, as it mentions "character with ID 1002".

In our case, that object does not exist at all.

Sep 9 2022, 3:25 PM
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.

The section you linked mentions null values in Non-Null fields, but not of null values for objects with a Non-Null field.

Are you sure this is disallowed by the standard, not "only" a bug in the GraphQL library we use?

Sep 9 2022, 3:04 PM
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.

The section you linked mentions null values in Non-Null fields, but not of null values for objects with a Non-Null field.

Are you sure this is disallowed by the standard, not "only" a bug in the GraphQL library we use?

Sep 9 2022, 2:51 PM
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.

The issue is snapshot has non nullable fields (like SWHID) and GraphQL standard will not allow a
null for an object with non nullable field without an error.

I can't find what part of the standard disallows it, nor any mention one way or another outside the standard. Any pointer?

Sep 9 2022, 2:34 PM
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.
> I do not get the issue here, using the following changes on top of your diff, it works as expected:
>

It will work as expected in the data part. But there will be an error associated, that we think is unnecessary.
With your changes, it will be a "NoneType' object has no attribute 'object_id" instead of an ObjectError

Could you write a snippet query to reproduce the error ? I still do not get what's wrong here.

Sep 9 2022, 2:12 PM
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.
> I do not get the issue here, using the following changes on top of your diff, it works as expected:
>

It will work as expected in the data part. But there will be an error associated, that we think is unnecessary.
With your changes, it will be a "NoneType' object has no attribute 'object_id" instead of an ObjectError

Sep 9 2022, 2:07 PM
jayeshv triaged T4518: GraphQL: Handle missing reference object errors as Low priority.
Sep 9 2022, 12:41 PM · GraphQL API
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.

Why have two different types, instead of making the snapshot field nullable, like this?

type VisitStatus {
  status: String!
  date: DateTime!
  type: String
  snapshot: Snapshot
}
Sep 9 2022, 12:35 PM
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.

@vlorentz The right fix is to add a new visit status type to the schema like below.

Sep 9 2022, 12:16 PM
jayeshv closed T4508: GraphQL: Add a directoryEntry entry point, a subtask of T4083: New public API (GraphQL + thin layer), as Resolved.
Sep 9 2022, 12:00 PM · GraphQL API, Roadmap 2022
jayeshv closed T4508: GraphQL: Add a directoryEntry entry point as Resolved.
Sep 9 2022, 12:00 PM · GraphQL API
jayeshv closed D8435: Add revision object as a possible directory entry target.
Sep 9 2022, 11:59 AM
jayeshv committed rDGQL6e5d34e94de1: Add revision object as a possible directory entry target (authored by jayeshv).
Add revision object as a possible directory entry target
Sep 9 2022, 11:59 AM
jayeshv requested review of D8435: Add revision object as a possible directory entry target.
Sep 9 2022, 11:57 AM
jayeshv closed D8396: Add a directoryEntry entrypoint.
Sep 9 2022, 11:47 AM
jayeshv committed rDGQL1af442fd62fd: Add a directoryEntry entrypoint (authored by jayeshv).
Add a directoryEntry entrypoint
Sep 9 2022, 11:47 AM
jayeshv added inline comments to D8396: Add a directoryEntry entrypoint.
Sep 9 2022, 11:46 AM
jayeshv updated the diff for D8396: Add a directoryEntry entrypoint.

remove ununsed test

Sep 9 2022, 11:21 AM
jayeshv added inline comments to D8396: Add a directoryEntry entrypoint.
Sep 9 2022, 11:16 AM
jayeshv updated the diff for D8396: Add a directoryEntry entrypoint.

use parametrize in directory entry tests

Sep 9 2022, 11:12 AM
jayeshv added inline comments to D8396: Add a directoryEntry entrypoint.
Sep 9 2022, 10:56 AM
jayeshv updated the diff for D8396: Add a directoryEntry entrypoint.

remove wrong code

Sep 9 2022, 8:50 AM
jayeshv added inline comments to D8396: Add a directoryEntry entrypoint.
Sep 9 2022, 8:47 AM
jayeshv updated the diff for D8396: Add a directoryEntry entrypoint.

address review comments

Sep 9 2022, 8:44 AM

Sep 8 2022

jayeshv updated the diff for D8396: Add a directoryEntry entrypoint.

rebase

Sep 8 2022, 5:40 PM
jayeshv accepted D8427: Convert SWHID to str before passing to sentry_sdk.set_tag.
Sep 8 2022, 5:27 PM
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.

Should this really be an error? Isn't it enough to set snapshot to null?

Sep 8 2022, 5:26 PM
jayeshv added a comment to D8426: Return none for missing snapshot in a visit status.

Should this really be an error? Isn't it enough to set snapshot to null?

Sep 8 2022, 5:08 PM
jayeshv added a comment to T4514: graphql: object_id must be <class 'bytes'> (got None that is a <class 'NoneType'>).

This is a bit tricky to fix.
Snapshot is available only in a visit status with 'full' status. But there is only one visit-status object and it has a field snapshot.
Did a fix that returns a sensible error instead of a creepy one.

Sep 8 2022, 5:04 PM · GraphQL API
jayeshv requested review of D8426: Return none for missing snapshot in a visit status.
Sep 8 2022, 5:03 PM
jayeshv added a revision to T4514: graphql: object_id must be <class 'bytes'> (got None that is a <class 'NoneType'>): D8426: Return none for missing snapshot in a visit status.
Sep 8 2022, 4:58 PM · GraphQL API
jayeshv claimed T4514: graphql: object_id must be <class 'bytes'> (got None that is a <class 'NoneType'>).
Sep 8 2022, 4:56 PM · GraphQL API
jayeshv requested review of D8425: Return more information with revision and release dates.
Sep 8 2022, 3:43 PM
jayeshv added a revision to T4365: GraphQL: Use the right date time serialization: D8425: Return more information with revision and release dates.
Sep 8 2022, 3:40 PM · GraphQL API
jayeshv updated the task description for T4365: GraphQL: Use the right date time serialization.
Sep 8 2022, 3:32 PM · GraphQL API
jayeshv updated the summary of D8396: Add a directoryEntry entrypoint.
Sep 8 2022, 10:14 AM
jayeshv added a revision to T4508: GraphQL: Add a directoryEntry entry point: D8396: Add a directoryEntry entrypoint.
Sep 8 2022, 10:14 AM · GraphQL API
jayeshv updated the diff for D8396: Add a directoryEntry entrypoint.

update the commit message

Sep 8 2022, 10:14 AM
jayeshv triaged T4508: GraphQL: Add a directoryEntry entry point as Normal priority.
Sep 8 2022, 10:12 AM · GraphQL API

Sep 6 2022

jayeshv added a comment to D8396: Add a directoryEntry entrypoint.

As this allows nested paths, then the cost calculator needs to take into account the number of / in the path, as each of them requires two joins in the database

Sep 6 2022, 11:42 AM
jayeshv requested review of D8396: Add a directoryEntry entrypoint.
Sep 6 2022, 11:32 AM

Sep 5 2022

jayeshv accepted D8395: settings/tests: Ensure swh_extra_django_apps correct value for tests.
Sep 5 2022, 4:57 PM
jayeshv accepted D8394: webapp/templates/layout: Fix deposit moderation view integration.
Sep 5 2022, 4:51 PM
jayeshv closed T4492: GraphQL: rename type fields to targetType for consistency as Resolved.
Sep 5 2022, 3:47 PM · GraphQL API
jayeshv closed T4492: GraphQL: rename type fields to targetType for consistency, a subtask of T4083: New public API (GraphQL + thin layer), as Resolved.
Sep 5 2022, 3:47 PM · GraphQL API, Roadmap 2022
jayeshv closed D8389: Rename 'type' field to 'targetType' in the schema.
Sep 5 2022, 3:46 PM
jayeshv committed rDGQL467e0b7e28bc: Rename 'type' field to 'targetType' in the schema (authored by jayeshv).
Rename 'type' field to 'targetType' in the schema
Sep 5 2022, 3:46 PM
jayeshv added inline comments to D8389: Rename 'type' field to 'targetType' in the schema.
Sep 5 2022, 3:38 PM
jayeshv requested review of D8389: Rename 'type' field to 'targetType' in the schema.
Sep 5 2022, 3:10 PM
jayeshv added a revision to T4492: GraphQL: rename type fields to targetType for consistency: D8389: Rename 'type' field to 'targetType' in the schema.
Sep 5 2022, 2:49 PM · GraphQL API
jayeshv triaged T4493: GraphQL: Create consistent ID fields as Normal priority.
Sep 5 2022, 9:35 AM · GraphQL API
jayeshv triaged T4492: GraphQL: rename type fields to targetType for consistency as Normal priority.
Sep 5 2022, 9:31 AM · GraphQL API

Sep 2 2022

jayeshv updated the diff for D8077: Add a static query cost calculator to reject malicious quries.

add a custom validator

Sep 2 2022, 3:07 PM
jayeshv closed D8382: Raise InvalidInputError on an invalid SWHID input.
Sep 2 2022, 10:59 AM
jayeshv committed rDGQL6b1c5797f711: Raise InvalidInputError on an invalid SWHID input (authored by jayeshv).
Raise InvalidInputError on an invalid SWHID input
Sep 2 2022, 10:59 AM
jayeshv requested review of D8382: Raise InvalidInputError on an invalid SWHID input.
Sep 2 2022, 10:51 AM

Sep 1 2022

jayeshv closed D8374: Remove the option to use a WSGI server.
Sep 1 2022, 11:01 AM
jayeshv committed rDGQL660acc6aa448: Remove the option to use a WSGI server (authored by jayeshv).
Remove the option to use a WSGI server
Sep 1 2022, 11:01 AM
jayeshv requested review of D8374: Remove the option to use a WSGI server.
Sep 1 2022, 10:54 AM

Aug 31 2022

jayeshv closed D8365: Remove unused middlewares package.
Aug 31 2022, 4:36 PM
jayeshv committed rDGQLce8008dfb321: Remove unused middlewares package (authored by jayeshv).
Remove unused middlewares package
Aug 31 2022, 4:36 PM
jayeshv requested review of D8365: Remove unused middlewares package.
Aug 31 2022, 4:30 PM
jayeshv closed D8356: Add a centralized error handler.
Aug 31 2022, 4:16 PM
jayeshv committed rDGQLcae785639016: Add a centralized error handler (authored by jayeshv).
Add a centralized error handler
Aug 31 2022, 4:16 PM
jayeshv added inline comments to D8356: Add a centralized error handler.
Aug 31 2022, 4:07 PM
jayeshv updated the diff for D8356: Add a centralized error handler.

address review comments

Aug 31 2022, 4:05 PM
jayeshv updated the diff for D8356: Add a centralized error handler.

Unit tests

Aug 31 2022, 3:33 PM
jayeshv updated the diff for D8356: Add a centralized error handler.

post to sentry

Aug 31 2022, 2:03 PM
jayeshv retitled D8356: Add a centralized error handler from [WIP] Add a centralized error handler to Add a centralized error handler.
Aug 31 2022, 1:47 PM
jayeshv updated the diff for D8356: Add a centralized error handler.

doc improvements

Aug 31 2022, 1:46 PM
jayeshv updated subscribers of D8356: Add a centralized error handler.
Aug 31 2022, 12:03 PM
jayeshv requested review of D8356: Add a centralized error handler.
Aug 31 2022, 12:02 PM
jayeshv added a revision to T4300: GraphQL: Collect code metric and add logging: D8356: Add a centralized error handler.
Aug 31 2022, 12:00 PM · GraphQL API

Aug 30 2022

jayeshv updated the diff for D8077: Add a static query cost calculator to reject malicious quries.

doc string update

Aug 30 2022, 5:45 PM
jayeshv updated the diff for D8077: Add a static query cost calculator to reject malicious quries.

fix tests

Aug 30 2022, 5:00 PM
jayeshv retitled D8077: Add a static query cost calculator to reject malicious quries from [WIP] Add a basic query cost validator to [WIP] Add a static query cost calculator to reject malicious quries.
Aug 30 2022, 3:23 PM
jayeshv updated the diff for D8077: Add a static query cost calculator to reject malicious quries.

Using multipliers

Aug 30 2022, 3:23 PM
jayeshv accepted D8342: Remove empty api_data.py file in root directory.
Aug 30 2022, 11:52 AM
jayeshv accepted D8337: misc/metrics: Move feature into its own django application.
Aug 30 2022, 11:28 AM

Aug 29 2022

jayeshv requested review of D8334: [WIP] Add a dynamic query cost calculator.
Aug 29 2022, 4:03 PM
jayeshv added a revision to T4299: GraphQL: Static query validation and max cost limiting: D8334: [WIP] Add a dynamic query cost calculator.
Aug 29 2022, 4:00 PM · GraphQL API

Aug 26 2022

jayeshv closed T4366: GraphQL: add revision log to the revision type, a subtask of T4083: New public API (GraphQL + thin layer), as Resolved.
Aug 26 2022, 3:56 PM · GraphQL API, Roadmap 2022
jayeshv closed T4366: GraphQL: add revision log to the revision type as Resolved.
Aug 26 2022, 3:56 PM · GraphQL API
jayeshv closed D8323: Remove hard-coded object ids from functional tests.
Aug 26 2022, 3:39 PM
jayeshv committed rDGQL4478a533a9b1: Remove hard-coded object ids from functional tests (authored by jayeshv).
Remove hard-coded object ids from functional tests
Aug 26 2022, 3:39 PM
jayeshv updated the diff for D8323: Remove hard-coded object ids from functional tests.

rebase

Aug 26 2022, 3:36 PM
jayeshv closed D8319: Enable cors in the asgi server.

97aa757412b725b08cc123620de9cd121f44778b

Aug 26 2022, 3:34 PM
jayeshv requested review of D8323: Remove hard-coded object ids from functional tests.
Aug 26 2022, 3:32 PM
jayeshv committed rDGQL97aa757412b7: Enable cors for the asgi server (authored by jayeshv).
Enable cors for the asgi server
Aug 26 2022, 3:32 PM
jayeshv retitled D8319: Enable cors in the asgi server from Enable cors in the dev server to Enable cors in the asgi server.
Aug 26 2022, 2:57 PM
jayeshv updated the diff for D8319: Enable cors in the asgi server.

Changed dev to asgi in the the doc and commit message

Aug 26 2022, 2:55 PM
jayeshv added inline comments to D8310: Add revision log field in the revision type.
Aug 26 2022, 2:42 PM
jayeshv added inline comments to D8319: Enable cors in the asgi server.
Aug 26 2022, 2:41 PM
jayeshv closed D8310: Add revision log field in the revision type.
Aug 26 2022, 2:39 PM
jayeshv committed rDGQLa31419d74c45: Add revision log field in the revision type (authored by jayeshv).
Add revision log field in the revision type
Aug 26 2022, 2:39 PM
jayeshv updated the diff for D8310: Add revision log field in the revision type.

fix typo

Aug 26 2022, 2:34 PM
jayeshv added inline comments to D8310: Add revision log field in the revision type.
Aug 26 2022, 2:30 PM
jayeshv requested review of D8319: Enable cors in the asgi server.
Aug 26 2022, 2:18 PM