You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@devlake.apache.org by "kostas-petrakis (via GitHub)" <gi...@apache.org> on 2024/12/10 15:54:05 UTC

[I] [Question][Module Name] Question title [incubator-devlake]

kostas-petrakis opened a new issue, #8237:
URL: https://github.com/apache/incubator-devlake/issues/8237

   <!--
   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.
   -->
   
   ## Question: ScopeId as varchar in BlueprintScope causing Jira plugin issues
   
   I'm working on fixing some PostgreSQL-related issues and noticed that the `ScopeId` field in the `BlueprintScope` struct is defined as a `string`:
   
   ```go
   type BlueprintScope struct {
   	BlueprintId  uint64 `json:"-" gorm:"primaryKey" validate:"required"`
   	PluginName   string `json:"-" gorm:"primaryKey;type:varchar(255)" validate:"required"`
   	ConnectionId uint64 `json:"-" gorm:"primaryKey" validate:"required"`
   	ScopeId      string `json:"scopeId" gorm:"primaryKey;type:varchar(255)" validate:"required"`
   }
   ```
   
   This is causing errors when configuring the Jira plugin, specifically when `ScopeId` (which is a string) is compared with `board_id` (which seems to be a `bigint` in the Jira plugin's table):
   
   ```shell
   ERROR: operator does not exist: bigint = character varying (SQLSTATE 42883)\n\x1b[0m\x1b[33m[1.048ms] \x1b[34;1m[rows:0]\x1b[0m SELECT bp.id AS blueprint_id, bp.project_name, bps.scope_id, _tool_jira_boards.* FROM _devlake_blueprint_scopes bps LEFT JOIN _devlake_blueprints bp ON (bp.id = bps.blueprint_id) LEFT JOIN _tool_jira_boards ON (_tool_jira_boards.connection_id = bps.connection_id AND _tool_jira_boards.board_id = bps.scope_id) WHERE bps.plugin_name = 'jira' AND bps.connection_id = 2"
   
   
   2024/12/10 15:42:34 [Recovery] 2024/12/10 - 15:42:34 panic recovered:
   ERROR: operator does not exist: bigint = character varying (SQLSTATE 42883) (500)
   Wraps: (2) ERROR: operator does not exist: bigint = character varying (SQLSTATE 42883)
   ```
   
   I'm currently working on a workaround that involves checking the database dialect, but a cleaner solution might be to change `ScopeId` to `uint64`.
   
   Before I pursue that route, I wanted to check if there's a specific reason why `ScopeId` is defined as `string`. Is there a plugin or use case that relies on `ScopeId` being a string? Otherwise we could possibly convert this field type?


-- 
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@devlake.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Question][Blueprint] ScopeId field type [incubator-devlake]

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh closed issue #8237: [Question][Blueprint] ScopeId field type
URL: https://github.com/apache/incubator-devlake/issues/8237


-- 
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@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Question][Blueprint] ScopeId field type [incubator-devlake]

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on issue #8237:
URL: https://github.com/apache/incubator-devlake/issues/8237#issuecomment-2547436607

   How about replacing the last `%s` in the SQL with `cast(%s as varchar)`?
   
   Final product:
   ```
   LEFT JOIN %s ON (%s.connection_id = bps.connection_id AND cast(%s as varchar) = bps.scope_id)
   ```


-- 
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@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Question][Module Name] Question title [incubator-devlake]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #8237:
URL: https://github.com/apache/incubator-devlake/issues/8237#issuecomment-2532136340

   <!-- Answer -->
   The `ScopeId` in the `BlueprintScope` struct is indeed defined as a `string`, which is causing issues when compared with `bigint` fields like `board_id` in the Jira plugin's table. Unfortunately, there is no specific documentation or comments in the codebase explaining why `ScopeId` was initially defined as a string, nor is there information on other plugins or modules that might rely on `ScopeId` being a string <sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/backend/core/models/blueprint.go)</sup>.
   
   Changing `ScopeId` to `uint64` could potentially resolve the type mismatch issue you're encountering. However, it's important to consider the implications of such a change across the codebase. This change might affect other parts of the system that interact with `ScopeId`, so thorough testing would be necessary to ensure compatibility and functionality are maintained.
   
   If you decide to proceed with changing the data type, ensure that all related database fields and queries are updated accordingly to prevent further type mismatch errors.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   
   ---
   <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/acc04ff6-806c-4d0d-b07f-1ff1f50fd5ed?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/acc04ff6-806c-4d0d-b07f-1ff1f50fd5ed?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/acc04ff6-806c-4d0d-b07f-1ff1f50fd5ed?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/acc04ff6-806c-4d0d-b07f-1ff1f50fd5ed?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/acc04ff6-806c-4d0d-b07f-1ff1f50fd5ed?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/acc04ff6-806c-4d0d-b07f-1ff1f50fd5ed?feedback_type=other)</sup>
   


-- 
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@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Question][Blueprint] ScopeId field type [incubator-devlake]

Posted by "kostas-petrakis (via GitHub)" <gi...@apache.org>.
kostas-petrakis commented on issue #8237:
URL: https://github.com/apache/incubator-devlake/issues/8237#issuecomment-2538595416

   Hello @klesh sure, the query causing this issue is [this](https://github.com/apache/incubator-devlake/blob/main/backend/helpers/srvhelper/scope_config_service_helper.go#L85)
   The best solution would be to transform the field, but there is another workaround for Postgres which would be checking against the dialect and modifying the clause accordingly (though this looks a bit more ugly).


-- 
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@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Question][Blueprint] ScopeId field type [incubator-devlake]

Posted by "klesh (via GitHub)" <gi...@apache.org>.
klesh commented on issue #8237:
URL: https://github.com/apache/incubator-devlake/issues/8237#issuecomment-2538196541

   Changing `BlueprintScope.ScopeId` from `string` to `int` might resolve the Jira issue, but would break compatibility with other plugins that use a non-integer `ScopeId`, such as Jenkins (which uses a string).
   
   A better solution might be to convert the Jira board ID to a string before comparison.
   
   Could you also please share the location of the query in question?
   


-- 
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@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Question][Blueprint] ScopeId field type [incubator-devlake]

Posted by "kostas-petrakis (via GitHub)" <gi...@apache.org>.
kostas-petrakis commented on issue #8237:
URL: https://github.com/apache/incubator-devlake/issues/8237#issuecomment-2548017847

   @klesh perfect! this does the trick, I will open a PR, meanwhile I found another small issue with the scope config, where the regex fails to save most likely due to the escaping (will open a followup).


-- 
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@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org