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

Add Unknown type to TaskInfoType #542

Merged
merged 14 commits into from
Aug 5, 2024
Merged

Conversation

postmeback
Copy link
Contributor

Pull Request

Related issue

Fixes #385

What does this PR do?

  • Currently, it adds the "Unknown" type to the enum. It requires more tasks to do

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

As discussed, can you add tests? 😊

@curquiza curquiza added the enhancement New feature or request label Jun 27, 2024
@curquiza curquiza changed the title Unknown Type Added Add Unknown type to TaskInfoType Jun 27, 2024
@curquiza curquiza changed the title Add Unknown type to TaskInfoType Add Unknown type to TaskInfoType Jun 27, 2024
@postmeback
Copy link
Contributor Author

Yeah, I will. This PR will get updated soon.

@postmeback
Copy link
Contributor Author

Yeah, I will. This PR will get updated soon.

I have updated this PR, to the best of my capabilities. Please review and provide feedback.

@postmeback
Copy link
Contributor Author

Seems like the build failed, Can you guide me on where to look?
@curquiza

@curquiza
Copy link
Member

curquiza commented Jul 3, 2024

@postmeback
The tests on main are green, so it's something you added that broke the CI.
Please, run the tests locally, you will have a better view of what is happening to fix them.

@postmeback
Copy link
Contributor Author

Well, I tried to run the tests, and below is the response.I have commented my tests.

image

It seems I am restricted. Any idea on how to get past it ?

@curquiza
Copy link
Member

curquiza commented Jul 6, 2024

@postmeback there is not need for access to run the tests locally.
Did you follow the steps in the CONTRIBUTING.md?

@postmeback
Copy link
Contributor Author

I followed the steps and came up with below conclusion

CreateUnknownTaskAsync & GetTaskWithUnknownTypeAsync - this two methods have an URI, which I created and not added with API, that's the reason it is failing.

https://github.com/postmeback/meilisearch-dotnet/blob/c2934b51bae7b0f243009af109f26499cb7585a0/src/Meilisearch/MeilisearchClient.cs#L430

https://github.com/postmeback/meilisearch-dotnet/blob/c2934b51bae7b0f243009af109f26499cb7585a0/src/Meilisearch/MeilisearchClient.cs#L438C37-L438C64

Requesting you to have a look.

@curquiza
Copy link
Member

curquiza commented Jul 8, 2024

@postmeback CreateUnknownTaskAsync call a route that does not exist in Meilisearch. It cannot work.

Maybe @ahmednfwela can guide you on this, or @brunoocasali who opened the issue.

Copy link
Collaborator

@ahmednfwela ahmednfwela left a comment

Choose a reason for hiding this comment

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

to address the issue, we just need to configure the json serializer used by meilisearch to fallback to the unknown enum value

Comment on lines 428 to 445


public async Task<TaskInfo> CreateUnknownTaskAsync(UnknownTaskQuery query, CancellationToken cancellationToken = default)
{
var response = await _http.PostAsJsonAsync("create-unknown-task", query, Constants.JsonSerializerOptionsRemoveNulls, cancellationToken: cancellationToken)
.ConfigureAwait(false);

return await response.Content.ReadFromJsonAsync<TaskInfo>(cancellationToken: cancellationToken).ConfigureAwait(false);
}

public async Task<TaskInfo> GetTaskWithUnknownTypeAsync(GetTaskQuery query, CancellationToken cancellationToken = default)
{
var response = await _http.PostAsJsonAsync("get-task-with-unknown-type", query, Constants.JsonSerializerOptionsRemoveNulls, cancellationToken: cancellationToken)
.ConfigureAwait(false);

return await response.Content.ReadFromJsonAsync<TaskInfo>(cancellationToken: cancellationToken).ConfigureAwait(false);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

all of these are unnecessary

@@ -0,0 +1,12 @@
using System;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this new file is unnecessary

@@ -0,0 +1,13 @@
using System;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this new file is unnecessary

@postmeback
Copy link
Contributor Author

I have removed the unnecessary files and methods from this PR.

Also, if you can point to the json serializer file/function, which needs to be updated, that would greatly assist. @ahmednfwela

@ahmednfwela
Copy link
Collaborator

@postmeback we use the default one https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonstringenumconverter?view=net-8.0

if this converter doesn't have a fallback option, we can create a custom one that inherits it

@ahmednfwela
Copy link
Collaborator

check this SO question for similar solutions

@postmeback
Copy link
Contributor Author

Sure, thanks for the suggestion. I will update you soon.

@postmeback
Copy link
Contributor Author

image

With the latest changes and all tests passing

@postmeback
Copy link
Contributor Author

image

I ran the formatter as well.

Copy link
Collaborator

@ahmednfwela ahmednfwela left a comment

Choose a reason for hiding this comment

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

can you please replace the json converter annotation on top of the enum with the new converter

@postmeback
Copy link
Contributor Author

Done.

@ahmednfwela
Copy link
Collaborator

bors merge

meili-bors bot added a commit that referenced this pull request Aug 3, 2024
542: Add `Unknown` type to `TaskInfoType` r=ahmednfwela a=postmeback

# Pull Request

## Related issue
Fixes #385 

## What does this PR do?
- Currently, it adds the "Unknown" type to the enum. It requires more tasks to do

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: postmeback <[email protected]>
Co-authored-by: Clémentine <[email protected]>
Co-authored-by: Ahmed Fwela <[email protected]>
Co-authored-by: Arka Poddar <[email protected]>
Copy link
Contributor

meili-bors bot commented Aug 3, 2024

This PR was included in a batch that successfully built, but then failed to merge into main. It will not be retried.

Additional information:

{"message":"1 review requesting changes and 1 approving review by reviewers with write access.","documentation_url":"https://docs.github.com/articles/about-protected-branches","status":"422"}

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

missing my approval

bors merge

Copy link
Contributor

meili-bors bot commented Aug 5, 2024

Build succeeded:

@meili-bors meili-bors bot merged commit 70a7026 into meilisearch:main Aug 5, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add generic type to TaskInfoType to handle new Task type
3 participants