Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/services/error_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def self.validate_error_code!(error_code)
raise InvalidErrorCode, error_code unless error_codes.include?(error_code)
end

# rubocop:disable Layout/LineLength -- To keep readability of the error codes
def self.error_codes
{
missing_permission: { description: 'The user is not permitted to perform this operation' },
Expand Down Expand Up @@ -69,15 +70,26 @@ def self.error_codes
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' },
organization_not_found: { description: 'The organization with the given identifier was not found' },
invalid_runtime_function_id: { description: 'The runtime function ID is invalid' },
invalid_runtime_parameter_id: { description: 'The runtime parameter ID is invalid' },
referenced_value_not_found: { description: 'A referenced value could not be found' },
invalid_runtime_parameter_definition: { description: 'The runtime parameter definition is invalid' },
invalid_runtime_function_definition: { description: 'The runtime function definition is invalid' },
no_generic_type_for_identifier: { description: 'No generic type could be found for the given identifier' },
no_data_type_for_identifier: { description: 'No data type could be found for the given identifier' },
no_datatype_identifier_for_generic_key: { description: 'No data type identifier could be found for the given generic key' },
invalid_generic_mapper: { description: 'The generic mapper is invalid because of active model errors' },
invalid_data_type: { description: 'The data type is invalid because of active model errors' },

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' },

missing_primary_runtime: { description: 'The project is missing a primary runtime' },
missing_definition: { description: 'The primary runtime has more definitions than this one' },
outdated_definition: { description: 'The primary runtime has a newer definition than this one' },
}
end
# rubocop:enable Layout/LineLength
end

ErrorCode.prepend_extensions
12 changes: 7 additions & 5 deletions app/services/namespaces/projects/flows/create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def execute
unless flow.persisted?
t.rollback_and_return! ServiceResponse.error(
message: 'Failed to create flow',
payload: flow.errors
error_code: :invalid_flow,
details: flow.errors
)
end

Expand All @@ -58,7 +59,8 @@ def execute
if res.error?
t.rollback_and_return! ServiceResponse.error(
message: 'Flow validation failed',
payload: res.payload
error_code: :flow_validation_failed,
details: res.payload
)
end

Expand All @@ -85,7 +87,7 @@ def create_node_function(node_function_id, input_nodes, t)
if runtime_function_definition.nil?
t.rollback_and_return! ServiceResponse.error(
message: 'Invalid runtime function id',
payload: :invalid_runtime_function_id
error_code: :invalid_runtime_function_id
)
end

Expand All @@ -95,7 +97,7 @@ def create_node_function(node_function_id, input_nodes, t)
if runtime_parameter.nil?
t.rollback_and_return! ServiceResponse.error(
message: 'Invalid runtime parameter id',
payload: :invalid_runtime_parameter_id
error_code: :invalid_runtime_parameter_id
)
end

Expand All @@ -121,7 +123,7 @@ def create_node_function(node_function_id, input_nodes, t)
if reference_value.nil?
t.rollback_and_return! ServiceResponse.error(
message: 'Referenced node function not found',
payload: :referenced_value_not_found
error_code: :referenced_value_not_found
)
end

Expand Down
8 changes: 4 additions & 4 deletions app/services/runtimes/data_types/update_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def execute
sort_data_types(data_types).each do |data_type|
unless update_datatype(data_type, t)
t.rollback_and_return! ServiceResponse.error(message: 'Failed to update data type',
payload: data_type.errors)
error_code: :invalid_data_type, details: data_type.errors)
end
end

Expand Down Expand Up @@ -104,7 +104,7 @@ def find_data_type_identifier(parent_type_rule_config, t)
if generic_type.nil?
t.rollback_and_return! ServiceResponse.error(
message: "Could not find generic type with identifier #{identifier.generic_type.data_type_identifier}",
payload: :no_generic_type_for_identifier
error_code: :no_generic_type_for_identifier
)
end

Expand All @@ -127,7 +127,7 @@ def create_data_type_identifier(t, **kwargs)
if data_type_identifier.nil?
t.rollback_and_return! ServiceResponse.error(
message: "Could not find datatype identifier with #{kwargs}",
payload: :no_datatype_identifier_for_generic_key
error_code: :no_datatype_identifier_for_generic_key
)
end

Expand All @@ -139,7 +139,7 @@ def find_data_type(identifier, t)

if data_type.nil?
t.rollback_and_return! ServiceResponse.error(message: "Could not find datatype with identifier #{identifier}",
payload: :no_datatype_for_identifier)
error_code: :no_data_type_for_identifier)
end

data_type
Expand Down
2 changes: 1 addition & 1 deletion app/services/runtimes/flow_types/update_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def find_datatype(identifier, t)

if data_type.nil?
t.rollback_and_return! ServiceResponse.error(message: "Could not find datatype with identifier #{identifier}",
payload: :no_datatype_for_identifier)
error_code: :no_data_type_for_identifier)
end

data_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def update_mappers(generic_mappers, t)
if mapper.nil? || !mapper.save
t.rollback_and_return! ServiceResponse.error(
message: "Could not find or create generic mapper (#{generic_mapper})",
payload: :error_creating_generic_mapper
error_code: :invalid_generic_mapper
)
end
mapper
Expand Down Expand Up @@ -120,7 +120,7 @@ def find_data_type_identifier(identifier, t)
if generic_type.nil?
t.rollback_and_return! ServiceResponse.error(
message: "Could not find generic type with identifier #{identifier.generic_type.data_type_identifier}",
payload: :no_generic_type_for_identifier
error_code: :no_generic_type_for_identifier
)
end

Expand All @@ -143,7 +143,7 @@ def create_data_type_identifier(t, **kwargs)
if data_type_identifier.nil?
t.rollback_and_return! ServiceResponse.error(
message: "Could not find datatype identifier with #{kwargs}",
payload: :no_datatype_identifier_for_generic_key
error_code: :no_datatype_identifier_for_generic_key
)
end

Expand Down Expand Up @@ -186,7 +186,8 @@ def update_parameters(runtime_function_definition, parameters, db_parameters, t)
unless db_param.save
t.rollback_and_return! ServiceResponse.error(
message: 'Could not save runtime parameter definition',
payload: db_param.errors
error_code: :invalid_runtime_parameter_definition,
details: db_param.errors
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/users/identity/unlink_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(current_authentication, identity)
def execute
transactional do |t|
if identity.nil?
t.rollback_and_return! ServiceResponse.error(payload: :external_identity_does_not_exist,
t.rollback_and_return! ServiceResponse.error(error_code: :external_identity_does_not_exist,
message: 'Nil identity given')
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/users/mfa/backup_codes/rotate_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def generate_new_codes(t)
user: current_user)).persisted?
if i > 10
t.rollback_and_return! ServiceResponse.error(message: 'Failed to save valid backup code',
payload: :failed_to_save_valid_backup_code)
error_code: :failed_to_save_valid_backup_code)
end
i += 1
end
Expand Down
10 changes: 10 additions & 0 deletions docs/graphql/enum/errorcodeenum.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ Represents the available error responses
| `IDENTITY_VALIDATION_FAILED` | Failed to validate the external identity |
| `INCONSISTENT_NAMESPACE` | Resources are from different namespaces |
| `INVALID_ATTACHMENT` | The attachment is invalid because of active model errors |
| `INVALID_DATA_TYPE` | The data type is invalid because of active model errors |
| `INVALID_EXTERNAL_IDENTITY` | This external identity is invalid |
| `INVALID_FLOW` | The flow is invalid because of active model errors |
| `INVALID_FLOW_SETTING` | The flow setting is invalid because of active model errors |
| `INVALID_GENERIC_MAPPER` | The generic mapper is invalid because of active model errors |
| `INVALID_LOGIN_DATA` | Invalid login data provided |
| `INVALID_NAMESPACE_LICENSE` | The namespace license is invalid because of active model errors |
| `INVALID_NAMESPACE_MEMBER` | The namespace member is invalid because of active model errors |
Expand All @@ -35,6 +37,10 @@ Represents the available error responses
| `INVALID_ORGANIZATION` | The organization is invalid because of active model errors |
| `INVALID_PASSWORD_REPEAT` | The provided password repeat does not match the password |
| `INVALID_RUNTIME` | The runtime is invalid because of active model errors |
| `INVALID_RUNTIME_FUNCTION_DEFINITION` | The runtime function definition is invalid |
| `INVALID_RUNTIME_FUNCTION_ID` | The runtime function ID is invalid |
| `INVALID_RUNTIME_PARAMETER_DEFINITION` | The runtime parameter definition is invalid |
| `INVALID_RUNTIME_PARAMETER_ID` | The runtime parameter ID is invalid |
| `INVALID_SETTING` | Invalid setting provided |
| `INVALID_TOTP_SECRET` | The TOTP secret is invalid or cannot be verified |
| `INVALID_USER` | The user is invalid because of active model errors |
Expand All @@ -54,12 +60,16 @@ Represents the available error responses
| `NAMESPACE_NOT_FOUND` | The namespace with the given identifier was not found |
| `NAMESPACE_PROJECT_NOT_FOUND` | The namespace project with the given identifier was not found |
| `NAMESPACE_ROLE_NOT_FOUND` | The namespace role with the given identifier was not found |
| `NO_DATATYPE_IDENTIFIER_FOR_GENERIC_KEY` | No data type identifier could be found for the given generic key |
| `NO_DATA_TYPE_FOR_IDENTIFIER` | No data type could be found for the given identifier |
| `NO_FREE_LICENSE_SEATS` | There are no free license seats to complete this operation |
| `NO_GENERIC_TYPE_FOR_IDENTIFIER` | No generic type could be found for the given identifier |
| `NO_PRIMARY_RUNTIME` | The project does not have a primary runtime |
| `ORGANIZATION_NOT_FOUND` | The organization with the given identifier was not found |
| `OUTDATED_DEFINITION` | The primary runtime has a newer definition than this one |
| `PRIMARY_LEVEL_NOT_FOUND` | **Deprecated:** Outdated concept |
| `PROJECT_NOT_FOUND` | The namespace project with the given identifier was not found |
| `REFERENCED_VALUE_NOT_FOUND` | A referenced value could not be found |
| `REGISTRATION_DISABLED` | Self-registration is disabled |
| `RUNTIME_MISMATCH` | Resources are from different runtimes |
| `RUNTIME_NOT_FOUND` | The runtime with the given identifier was not found |
Expand Down