owasp-amass/amass · error

missing scheme in database URI

Error message

missing scheme in database URI

What it means

loadDatabase parses the configured database URI with url.Parse and validates its parts. A URI with no scheme (e.g. 'localhost:7687/user' without 'neo4j://') is rejected because the scheme identifies the database type the driver should use.

Source

Thrown at config/graphdb.go:111

	} else {
		dbURI = "postgres://" + u + "@" + h + ":" + port + "/" + n
	}
	db.URL = dbURI
	if c.GraphDBs == nil {
		c.GraphDBs = make([]*Database, 0)
	}
	c.GraphDBs = append(c.GraphDBs, db)
	return nil
}

func (c *Config) loadDatabase(dbURI string) error {
	u, err := url.Parse(dbURI)
	if err != nil {
		return err
	}
	// Check for valid scheme (database type)
	if u.Scheme == "" {
		return fmt.Errorf("missing scheme in database URI")
	}
	// Check for non-empty username
	if u.User == nil || u.User.Username() == "" {
		return fmt.Errorf("missing username in database URI")
	}
	// Check for reachable hostname
	if u.Hostname() == "" {
		return fmt.Errorf("missing hostname in database URI")
	}

	dbName := ""
	// Only get the database name if it's not empty or a single slash
	if u.Path != "" && u.Path != "/" {
		dbName = strings.TrimPrefix(u.Path, "/")
	}

	db := &Database{
		Primary:  true, // Set as primary, because it wouldn't be there otherwise.

View on GitHub (pinned to 79299dce87)

Solutions

  1. Prefix the URI with its database scheme, e.g. neo4j://host:7687/dbname.
  2. Validate the URI by running it through `python3 -c "import urllib.parse;print(urllib.parse.urlparse('...').scheme)"` or a similar parser before saving the config.
  3. Check the config file for quoting issues that may have stripped the scheme.

Example fix

// before
"database": "localhost:7687/mydb"
// after
"database": "neo4j://localhost:7687/mydb"
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse(dbURI)
if err != nil || u.Scheme == "" {
    return errors.New("database URI must include a scheme, e.g. neo4j://host")
}

Try / catch

if err := loadDatabase(uri); err != nil {
    if strings.Contains(err.Error(), "missing scheme") {
        uri = "neo4j://" + uri // or surface a config fix hint
    }
}

Prevention

When it happens

Trigger: A GraphDB URI in the config file that omits the scheme, e.g. 'localhost:7474' or 'user@host/db', passed to loadDatabase via loadDatabaseSettings.

Common situations: Hand-editing the config and dropping the 'neo4j://' or 'postgres://' prefix; config examples copied from tools that accept bare host:port; YAML values containing special chars that mangle the URI.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/6fc2a89aa26aeac3. Report an issue: GitHub.