instructure/canvas-lms · error
invalid import type parameter
Error message
invalid import type parameter
What it means
OutcomeImportsApiController#create raises a plain RuntimeError when the supplied import_type is not a registered OutcomeImport import type. The API only accepts import types the OutcomeImport model validates (defaulting to 'instructure_csv').
Solutions
- Send import_type=instructure_csv (the only universally supported value) in the request params.
- Check OutcomeImport.valid_import_type?(type) client-side before calling the API.
- Confirm any custom import types are registered in OutcomeImport on the target Canvas install.
- Provide the outcome data as CSV matching the instructure_csv format when unsure.
Example fix
// before POST outcome_imports?import_type=csv // invalid // after POST outcome_imports?import_type=instructure_csv
Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError unless OutcomeImport.valid_import_type?(import_type)
Try / catch
begin create_outcome_import(import_type: 'instructure_csv', attachment: csv_file) rescue RuntimeError => e retry with import_type: 'instructure_csv' if e.message == 'invalid import type parameter' end
Prevention
- Default to import_type=instructure_csv unless you know a custom type is registered.
- Check valid_import_type? before calling the API.
- Read the OutcomeImport model to see which types your install supports.
- Don't rely on Content-Type sniffing; always send an explicit import_type.
When it happens
Trigger: POST /api/v1/accounts/:id/outcome_imports (or courses equivalent) with import_type set to an unknown value like 'academic_csv' typo'd or unsupported for the install, or nil resolving to a type not enabled.
Common situations: Copy-pasting API examples using import types from other Canvas features; plugins defining import types not enabled; clients omitting import_type while sending a non-CSV body and assuming another format is inferred.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Cannot change locked status on granular permission
- GUID is invalid: #
- Invalid action.
- invalid calculation_int: #
- invalid calculation_method: #
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/e1f68baa9bfd081c.
Report an issue: GitHub.
Appendix: source
Thrown at app/controllers/outcome_imports_api_controller.rb:168
# 'https://<canvas>/api/v1/accounts/<account_id>/outcome_imports?import_type=instructure_csv'
#
# curl -H 'Content-Type: text/csv' --data-binary @<filename>.csv \
# -H "Authorization: Bearer <token>" \
# 'https://<canvas>/api/v1/courses/<course_id>/outcome_imports?import_type=instructure_csv'
#
#
# @argument extension [String]
# Recommended for raw post request style imports. This field will be used to
# distinguish between csv and other file format extensions that
# would usually be provided with the filename in the multipart post request
# scenario. If not provided, this value will be inferred from the
# Content-Type, falling back to csv-file format if all else fails.
#
# @returns OutcomeImport
def create
if authorized_action(@context, @current_user, :import_outcomes)
params[:import_type] ||= "instructure_csv"
raise "invalid import type parameter" unless OutcomeImport.valid_import_type?(params[:import_type])
file_obj = if params.key?(:attachment)
params[:attachment]
else
body_file
end
import = OutcomeImport.create_with_attachment(
@context, params[:import_type], file_obj, @current_user, params[:learning_outcome_group_id]
)
import.schedule
render json: outcome_import_json(import, @current_user, session)
end
end
# @API Get Outcome import status
#View on GitHub (pinned to 1c9f0bb801)