Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:OpenHands OpenHands OrgService Validate Name Uniqueness

From Leeroopedia
Knowledge Sources
Domains Organization_Management, Multi_Tenancy
Last Updated 2026-02-11 21:00 GMT

Overview

Concrete tool for validating organization name uniqueness provided by the OpenHands enterprise storage layer.

Description

OrgService.validate_name_uniqueness queries the organization table to determine whether an organization with the given name already exists. If a match is found, it raises an OrgNameExistsError, halting the onboarding workflow before any dependent resources (LiteLLM teams, API keys, database rows) are allocated. This ensures the fail-fast principle is honored at the earliest possible stage of organization creation.

The method performs a simple existence check against the Org model using the provided name string. It is designed to be called as the first step in the organization creation pipeline.

Usage

Call this method at the start of the organization onboarding workflow, before provisioning LiteLLM resources or creating the organization entity. It should be invoked any time a user-supplied organization name needs to be verified for uniqueness.

Code Reference

Source Location

  • Repository: OpenHands
  • File: enterprise/storage/org_service.py
  • Lines: L33-45

Signature

def validate_name_uniqueness(self, name: str) -> None:
    """Validate that no organization with the given name exists.

    Args:
        name: The proposed organization name to check.

    Raises:
        OrgNameExistsError: If an organization with this name already exists.
    """

Import

from enterprise.storage.org_service import OrgService

I/O Contract

Inputs

Name Type Required Description
name str Yes The proposed organization name to validate for uniqueness

Outputs

Name Type Description
(none) None Returns None on success; raises OrgNameExistsError if the name is already taken

Usage Examples

Basic Usage

from enterprise.storage.org_service import OrgService

org_service = OrgService(session=db_session)

# Validate before proceeding with creation
try:
    org_service.validate_name_uniqueness("acme-corp")
except OrgNameExistsError:
    # Handle duplicate name — inform the user
    raise HTTPException(status_code=409, detail="Organization name already taken")

# Safe to proceed with org creation

Related Pages

Implements Principle

Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment