From 586839c4bacb88caf67276ff6acca8fd0798c50f Mon Sep 17 00:00:00 2001 From: Dario Pranjic Date: Thu, 13 Nov 2025 21:58:12 +0100 Subject: [PATCH 1/3] fix some suggestions from copilot --- app/graphql/types/namespace_role_type.rb | 3 +++ app/services/error_code.rb | 1 + app/services/files/upload_service.rb | 4 ++-- app/services/users/identity/register_service.rb | 2 +- app/services/users/logout_service.rb | 2 +- spec/services/users/identity/register_service_spec.rb | 6 +++--- spec/support/helpers/graphql_helpers.rb | 4 ++-- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/graphql/types/namespace_role_type.rb b/app/graphql/types/namespace_role_type.rb index 15d9e5d8..f880abf0 100644 --- a/app/graphql/types/namespace_role_type.rb +++ b/app/graphql/types/namespace_role_type.rb @@ -15,6 +15,9 @@ class NamespaceRoleType < BaseObject field :assigned_projects, Types::NamespaceProjectType.connection_type, description: 'The projects this role is assigned to' + field :assigned_members, Types::NamespaceProjectType.connection_type, + description: 'The projects this role is assigned to' + expose_abilities %i[ assign_role_abilities assign_role_projects diff --git a/app/services/error_code.rb b/app/services/error_code.rb index 29c7c867..1dddcf7c 100644 --- a/app/services/error_code.rb +++ b/app/services/error_code.rb @@ -64,6 +64,7 @@ def self.error_codes namespace_project_not_found: { description: 'The namespace project with the given identifier was not found' }, namespace_member_not_found: { description: 'The namespace member with the given identifier was not found' }, license_not_found: { description: 'The namespace license with the given identifier was not found' }, + flow_type_not_found: { description: 'The flow type with the given identifier was not found' }, primary_level_not_found: { description: '', deprecation_reason: 'Outdated concept' }, secondary_level_not_found: { description: '', deprecation_reason: 'Outdated concept' }, tertiary_level_exceeds_parameters: { description: '', deprecation_reason: 'Outdated concept' }, diff --git a/app/services/files/upload_service.rb b/app/services/files/upload_service.rb index df68acf7..0cc400c3 100644 --- a/app/services/files/upload_service.rb +++ b/app/services/files/upload_service.rb @@ -27,8 +27,8 @@ def execute object.send(attachment_name).attach attachment unless object.save - ServiceResponse.error(message: 'Failed to save object', error_code: :invalid_attachment, - details: object.errors) + return ServiceResponse.error(message: 'Failed to save object', error_code: :invalid_attachment, + details: object.errors) end AuditService.audit( diff --git a/app/services/users/identity/register_service.rb b/app/services/users/identity/register_service.rb index 00812541..c6b592cb 100644 --- a/app/services/users/identity/register_service.rb +++ b/app/services/users/identity/register_service.rb @@ -57,7 +57,7 @@ def execute end user_session = UserSession.create(user: user) unless user_session.persisted? - t.rollback_and_return! ServiceResponse.error(message: :invalid_user_session, + t.rollback_and_return! ServiceResponse.error(error_code: :invalid_user_session, details: user_session.errors) end diff --git a/app/services/users/logout_service.rb b/app/services/users/logout_service.rb index 201b3804..5f4759c0 100644 --- a/app/services/users/logout_service.rb +++ b/app/services/users/logout_service.rb @@ -23,7 +23,7 @@ def execute ServiceResponse.success(message: 'Logged out session', payload: user_session) else logger.warn(message: 'Failed to log out session', session_id: user_session.id, user_id: user_session.user_id) - ServiceResponse.error(error_code: user_session.errors) + ServiceResponse.error(error_code: :invalid_user_session, details: user_session.errors) end end end diff --git a/spec/services/users/identity/register_service_spec.rb b/spec/services/users/identity/register_service_spec.rb index 8bab4f8d..18472dac 100644 --- a/spec/services/users/identity/register_service_spec.rb +++ b/spec/services/users/identity/register_service_spec.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: true + # frozen_string_literal: true require 'rails_helper' @@ -58,7 +58,7 @@ def setup_identity_provider(identity) shared_examples 'invalid user' do |error_code| it { is_expected.not_to be_success } - it { expect(service_response[:error_code]).to eq(error_code) } + it { expect(service_response.payload[:error_code]).to eq(error_code) } it { expect { service_response }.not_to create_audit_event } end @@ -183,7 +183,7 @@ def setup_identity_provider(identity) end it { is_expected.not_to be_success } - it { expect(service_response[:error_code]).to eq(:invalid_user_identity) } + it { expect(service_response.payload[:error_code]).to eq(:invalid_user_identity) } it { expect { service_response }.not_to create_audit_event } it { expect(service_response.payload[:details].full_messages).to include('Identifier has already been taken') } end diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb index 979f0fae..a48f537e 100644 --- a/spec/support/helpers/graphql_helpers.rb +++ b/spec/support/helpers/graphql_helpers.rb @@ -79,8 +79,8 @@ def error_query errors { errorCode details { - ...on ActiveModelError { attribute type } - ...on MessageError { message } + ...on ActiveModelError { attribute type } + ...on MessageError { message } } } ) From 2786b851575f9e85932bce5059219c3741dbab8b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Nov 2025 21:04:22 +0000 Subject: [PATCH 2/3] Initial plan From d1515ce5f80882675de3d23d364bf21c1d6386cf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Nov 2025 21:08:05 +0000 Subject: [PATCH 3/3] Fix grammar typos: change "an flow" to "a flow" Co-authored-by: Knerio <96529060+Knerio@users.noreply.github.com> --- app/graphql/types/errors/flow_validation_error_type.rb | 2 +- app/graphql/types/namespace_project_type.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/graphql/types/errors/flow_validation_error_type.rb b/app/graphql/types/errors/flow_validation_error_type.rb index 4732064b..0c99d508 100644 --- a/app/graphql/types/errors/flow_validation_error_type.rb +++ b/app/graphql/types/errors/flow_validation_error_type.rb @@ -6,7 +6,7 @@ module Errors class FlowValidationErrorType < Types::BaseObject graphql_name 'FlowValidationError' # rubocop:enable GraphQL/GraphqlName - description 'Represents an flow validation error' + description 'Represents a flow validation error' field :details, Errors::ActiveModelErrorType, null: true, description: 'Additional details about the validation error' diff --git a/app/graphql/types/namespace_project_type.rb b/app/graphql/types/namespace_project_type.rb index 69ffa9da..e6512823 100644 --- a/app/graphql/types/namespace_project_type.rb +++ b/app/graphql/types/namespace_project_type.rb @@ -17,7 +17,7 @@ class NamespaceProjectType < Types::BaseObject field :primary_runtime, Types::RuntimeType, null: true, description: 'The primary runtime for the project' - field :flow, Types::FlowType, null: true, description: 'Fetches an flow given by its ID' do + field :flow, Types::FlowType, null: true, description: 'Fetches a flow given by its ID' do argument :id, Types::GlobalIdType[::Flow], required: true, description: 'Id of the flow' end