OpenRefine/OpenRefine · error · GetProjectIDException

Can't lookup a project with a null name

Error message

Can't lookup a project with a null name

What it means

GetProjectIDException thrown by ProjectManager.getProjectID when the supplied project name is null. A null name can never match any project, so the manager fails fast instead of doing a linear search.

Solutions

  1. Ensure the name argument is non-null before calling getProjectID
  2. Validate user/derived input: check for null/empty strings before lookup
  3. For expressions, use a default value (e.g. a named constant project) when the key is missing

Example fix

// before
long id = ProjectManager.singleton.getProjectID(name);
// after
if (name == null || name.isEmpty()) { throw new IllegalArgumentException("project name required"); }
long id = ProjectManager.singleton.getProjectID(name);
Defensive patterns

Strategy: type-guard

Validate before calling

if (name == null || name.trim().isEmpty()) {
    throw new IllegalArgumentException("Project name must be a non-empty string");
}

Type guard

boolean hasName(String s) { return s != null && !s.trim().isEmpty(); }

Try / catch

try { id = ProjectManager.singleton.getProjectID(name); }
catch (GetProjectIDException e) { /* handle missing/null/ambiguous name */ }

Prevention

When it happens

Trigger: Calling ProjectManager.singleton.getProjectID(null) directly, or passing an expression/cell result that evaluated to null as the project name.

Common situations: Scripting or extension code that resolves a project name from user data where the value is empty/null; forgetting to supply the project-name argument in a custom command.

Related errors


AI-assisted analysis of OpenRefine/OpenRefine@a946177e04 (2026-09-08). Data as JSON: /api/errors/ef1ac75d412d5ce5. Report an issue: GitHub.

Appendix: source

Thrown at modules/core/src/main/java/com/google/refine/ProjectManager.java:380

                return pm;
            }
        }
        return null;
    }

    /**
     * Tries to find the project id when given a project name Requires that all project metadata exists has been loaded
     * to memory from the data store
     * 
     * @param name
     *            The name of the project
     * @return The id of the project
     * @throws GetProjectIDException
     *             If no unique project is found with the given name
     */
    public long getProjectID(String name) throws GetProjectIDException {
        if (name == null) {
            throw new GetProjectIDException("Can't lookup a project with a null name");
        }
        Integer count = 0;
        Long id = -1L;
        // TODO: Linear search assumes small number of projects
        for (Entry<Long, ProjectMetadata> entry : _projectsMetadata.entrySet()) {
            ProjectMetadata metadata = entry.getValue();
            if (metadata != null && name.equals(metadata.getName())) {
                id = entry.getKey();
                count += 1;
            }
        }
        if (count == 1) {
            return id;
        } else if (count == 0) {
            throw new GetProjectIDException("Unable to find project with name: " + name);
        }
        throw new GetProjectIDException("Multiple (" + count + ") projects found with name: " + name);
    }

View on GitHub (pinned to a946177e04)