You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by "ittuann (via GitHub)" <gi...@apache.org> on 2024/05/16 13:09:41 UTC
[PR] fix: Replace hard-coded identifier in VersionEndpoint.get() method
ittuann opened a new pull request, #2871:
URL: https://github.com/apache/streampipes/pull/2871
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<!--
Thanks for contributing! Here are some tips you can follow to help us incorporate your contribution quickly and easily:
1. If this is your first time, please read our contributor guidelines:
- https://streampipes.apache.org/getinvolved.html
- https://cwiki.apache.org/confluence/display/STREAMPIPES/Getting+Started
2. Make sure the PR title is formatted like: `[#<GitHub issue id>] PR title ...`
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., `[WIP][#<GitHub issue id>] PR title ...`.
4. Please write your PR title to summarize what this PR proposes/fixes.
5. Link the PR to the corresponding GitHub issue (if present) in the `Development` section in the right menu bar.
6. Be sure to keep the PR description updated to reflect all changes.
7. If possible, provide a concise example to reproduce the issue for a faster review.
8. Make sure tests pass via `mvn clean install`.
9. (Optional) If the contribution is large, please file an Apache ICLA
- http://apache.org/licenses/icla.pdf
-->
### Purpose
<!--
Please clarify what changes you are proposing and describe how those changes will address the issue.
Furthermore, describe potential consequences the changes might have.
-->
The `get` method in the `VersionEndpoint` class internally hard-codes the `identifier` parameter to an empty string `""`, which can be misleading.
When users call the `get` method and pass any identifier, the method always uses an empty string as the identifier. This may lead users to mistakenly believe that their incorrect get request has successfully returned the correct result.

With this fix, when users provide an invalid identifier, the method will now throw an appropriate error, ensuring that users can promptly detect the issue and make corrections.

Additionally, I also added tests to ensure that the new error handling behaves as expected.
### Remarks
<!--
Is there anything left we need to pay attention on?
Are there some references that might be important? E.g. links to Confluence, or discussions
on the mailing list or GitHub.
-->
PR introduces (a) breaking change(s): <yes/no>
no
PR introduces (a) deprecation(s): <yes/no>
no
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Replace hard-coded identifier in VersionEndpoint.get() method
Posted by "ittuann (via GitHub)" <gi...@apache.org>.
ittuann commented on code in PR #2871:
URL: https://github.com/apache/streampipes/pull/2871#discussion_r1604514568
##########
streampipes-client-python/streampipes/endpoint/api/version.py:
##########
@@ -109,11 +109,20 @@ def get(self, identifier: str, **kwargs) -> Resource:
identifier: str
Not supported by this endpoint, is set to an empty string.
+ Raises
+ ------
+ NotImplementedError
+ Non-empty 'identifier' is not supported by this endpoint. Please set 'identifier' to an empty string.
+
Returns
-------
versions: Version
The specified resource as an instance of the corresponding model class([Version][streampipes.model.resource.Version]). # noqa: 501
"""
+ if identifier != "":
+ raise NotImplementedError(
Review Comment:
Thank you for your feedback! I understand your point and will modify the code as per your suggestion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Replace hard-coded identifier in VersionEndpoint.get() method
Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti merged PR #2871:
URL: https://github.com/apache/streampipes/pull/2871
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Replace hard-coded identifier in VersionEndpoint.get() method
Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti commented on code in PR #2871:
URL: https://github.com/apache/streampipes/pull/2871#discussion_r1604424214
##########
streampipes-client-python/streampipes/endpoint/api/version.py:
##########
@@ -109,11 +109,20 @@ def get(self, identifier: str, **kwargs) -> Resource:
identifier: str
Not supported by this endpoint, is set to an empty string.
+ Raises
+ ------
+ NotImplementedError
+ Non-empty 'identifier' is not supported by this endpoint. Please set 'identifier' to an empty string.
+
Returns
-------
versions: Version
The specified resource as an instance of the corresponding model class([Version][streampipes.model.resource.Version]). # noqa: 501
"""
+ if identifier != "":
Review Comment:
Shall we change that to `if identifier:`? This would allow the user to pass `None` as well which is semantically correct.
##########
streampipes-client-python/streampipes/endpoint/api/version.py:
##########
@@ -109,11 +109,20 @@ def get(self, identifier: str, **kwargs) -> Resource:
identifier: str
Not supported by this endpoint, is set to an empty string.
+ Raises
+ ------
+ NotImplementedError
+ Non-empty 'identifier' is not supported by this endpoint. Please set 'identifier' to an empty string.
+
Returns
-------
versions: Version
The specified resource as an instance of the corresponding model class([Version][streampipes.model.resource.Version]). # noqa: 501
"""
+ if identifier != "":
+ raise NotImplementedError(
Review Comment:
I suggest to use `ValueError`
This is not the intended use for `NotImplementedError` (https://docs.python.org/3/library/exceptions.html#NotImplementedError).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Replace hard-coded identifier in VersionEndpoint.get() method
Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti commented on code in PR #2871:
URL: https://github.com/apache/streampipes/pull/2871#discussion_r1604535712
##########
streampipes-client-python/streampipes/endpoint/api/version.py:
##########
@@ -109,11 +109,20 @@ def get(self, identifier: str, **kwargs) -> Resource:
identifier: str
Not supported by this endpoint, is set to an empty string.
+ Raises
+ ------
+ ValueError
+ Non-empty 'identifier' is not supported by this endpoint. Please set 'identifier' to an empty string.
+
Returns
-------
versions: Version
The specified resource as an instance of the corresponding model class([Version][streampipes.model.resource.Version]). # noqa: 501
"""
+ if identifier:
+ raise ValueError(
+ "Non-empty 'identifier' is not supported by this endpoint. Please set 'identifier' to an empty string."
Review Comment:
```suggestion
"Non-empty 'identifier' is not supported by this endpoint. Please set 'identifier' to an empty string or 'None'."
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Replace hard-coded identifier in VersionEndpoint.get() method
Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti commented on code in PR #2871:
URL: https://github.com/apache/streampipes/pull/2871#discussion_r1604535328
##########
streampipes-client-python/streampipes/endpoint/api/version.py:
##########
@@ -109,11 +109,20 @@ def get(self, identifier: str, **kwargs) -> Resource:
identifier: str
Not supported by this endpoint, is set to an empty string.
+ Raises
+ ------
+ ValueError
+ Non-empty 'identifier' is not supported by this endpoint. Please set 'identifier' to an empty string.
Review Comment:
```suggestion
Non-empty `identifier` is not supported by this endpoint. Please set `identifier` to an empty string or `None`.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org