instructure/canvas-lms · error · Common::ConfigurationError
Invalid URI in pv5 config: #
Error message
Invalid URI in pv5 config: #{e.message} What it means
After loading the pv5 config (optionally selecting a regional override via get_regional_config), PageViews::Configuration parses the 'uri' value with URI.parse. A URI::InvalidURIError is rescued and re-raised as Common::ConfigurationError, 'Invalid URI in pv5 config: <detail>', because the configured page-view endpoint is malformed.
Solutions
- Fix the 'uri' value in the pv5 config (top-level or the relevant regions entry) to a well-formed absolute URL.
- Run URI.parse(uri) locally against the configured value to reproduce and pinpoint the invalid characters.
- Check the regional config under config['regions'][region] — a bad regional uri takes precedence over the valid default.
- Validate config at deploy time (URI.parse) so bad values never reach runtime.
Example fix
# before (config/page_views.yml) production: uri: https://pageviews.example .com/events # after production: uri: https://pageviews.example.com/events
Defensive patterns
Strategy: validation
Validate before calling
uri = config.dig('regions', region, 'uri') || config['uri']
URI.parse(uri.to_s) # raises URI::InvalidURIError early if malformed Try / catch
begin PageViews::Configuration.new(region: region) rescue Common::ConfigurationError => e Rails.logger.error(e.message) alert_on_bad_pv5_config end
Prevention
- Validate pv5 uri values with URI.parse at config load/deploy time
- Avoid placeholders or uninterpolated templates in config uris
- Audit regional overrides under config['regions'] for bad uris
- Trim whitespace/quotes when entering endpoint values into config stores
When it happens
Trigger: pv5 config (top-level or regional, config['regions'][region]) contains a 'uri' value that URI.parse rejects — e.g. contains spaces or unescaped characters, is a template with unexpanded placeholders, or has protocol/control characters.
Common situations: Copy-pasted endpoint with trailing whitespace or quotes; uninterpolated ERB/placeholder like http://${HOST}; regional config entry with a bad or empty uri overriding a valid default; hand-edited config store values.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- PV5 is not configured for this environment
- an object with an interface for loading settings must be…
- an object with an interface for loading settings must be…
- Invalid mode: #
- invalid request
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/3463e4416f7df74c.
Report an issue: GitHub.
Appendix: source
Thrown at app/services/page_views/configuration.rb:35
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
module PageViews
class Configuration
attr_reader :uri
def self.configured?
ConfigFile.load("pv5").present?
end
def initialize(region: nil)
config = ConfigFile.load("pv5")
raise Common::ConfigurationError, "PV5 is not configured for this environment" unless config.present?
regional_config = get_regional_config(config, region) || {}
@uri = URI.parse(regional_config["uri"] || config["uri"])
rescue URI::InvalidURIError => e
raise Common::ConfigurationError, "Invalid URI in pv5 config: #{e.message}"
end
private
def get_regional_config(config, region)
return unless config["regions"].is_a?(Hash)
regional_config = config["regions"][region]
return unless regional_config.is_a?(Hash)
regional_config
end
end
end
View on GitHub (pinned to 1c9f0bb801)