# Buggy code
def populate_validators(self) -> None:
    """
    Prepare self.pre_validators, self.validators, and self.post_validators based on self.type_'s  __get_validators__
    and class validators. This method should be idempotent, e.g. it should be safe to call multiple times
    without mis-configuring the field.
    """
    class_validators_ = self.class_validators.values()
    if not self.sub_fields or self.shape == SHAPE_GENERIC:
        get_validators = getattr(self.type_, "__get_validators__", None)
        v_funcs = (
            *[v.func for v in class_validators_ if v.each_item and v.pre],
            *(
                get_validators()
                if get_validators
                else list(find_validators(self.type_, self.model_config))
            ),
            *[v.func for v in class_validators_ if v.each_item and not v.pre],
        )
        self.validators = prep_validators(v_funcs)

    # Add const validator
    self.pre_validators = []
    self.post_validators = []
    if self.field_info and self.field_info.const:
        self.pre_validators = [make_generic_validator(constant_validator)]

    if class_validators_:
        self.pre_validators += prep_validators(
            v.func for v in class_validators_ if not v.each_item and v.pre
        )
        self.post_validators = prep_validators(
            v.func for v in class_validators_ if not v.each_item and not v.pre
        )

    if self.parse_json:
        self.pre_validators.append(make_generic_validator(validate_json))

    self.pre_validators = self.pre_validators or None
    self.post_validators = self.post_validators or None


# Traceback (pydantic.error_wrappers.ValidationError)
import os
from pathlib import Path
import pydantic

class Config1(pydantic.BaseSettings):
...     port: int = pydantic.Field(1234, const=True)
...
class Config2(pydantic.BaseSettings):
...     port: int = pydantic.Field("1234", const=True)
...
print("No env")
No env
print("Config1", Config1().dict())
Config1 {'port': 1234}
print("Config2", Config2().dict())
Config2 {'port': 1234}

print("With .env")
With .env
Path(".env").write_text("port=1234\n")
10
print("Config1", Config1(_env_file=".env").dict())  # FAILS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\dev\github\pydantic\issues\.venv\lib\site-packages\pydantic\env_settings.py", line 28, in __init__
super().__init__(**__pydantic_self__._build_values(values, _env_file=_env_file))
File "D:\dev\github\pydantic\issues\.venv\lib\site-packages\pydantic\main.py", line 338, in __init__
raise validation_error
pydantic.error_wrappers.ValidationError: 1 validation error for Config1
port
unexpected value; permitted: 1234 (type=value_error.const; given=1234; permitted=[1234])
print("Config2", Config2(_env_file=".env").dict())
Config2 {'port': 1234}

print("With os.environ")
With os.environ
os.environ["port"] = "1234"
print("Config1", Config1().dict())  # FAILS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\dev\github\pydantic\issues\.venv\lib\site-packages\pydantic\env_settings.py", line 28, in __init__
super().__init__(**__pydantic_self__._build_values(values, _env_file=_env_file))
File "D:\dev\github\pydantic\issues\.venv\lib\site-packages\pydantic\main.py", line 338, in __init__
raise validation_error
pydantic.error_wrappers.ValidationError: 1 validation error for Config1
port
unexpected value; permitted: 1234 (type=value_error.const; given=1234; permitted=[1234])
print("Config2", Config2().dict())
Config2 {'port': 1234}

# Fixed code
def populate_validators(self) -> None:
    """
    Prepare self.pre_validators, self.validators, and self.post_validators based on self.type_'s  __get_validators__
    and class validators. This method should be idempotent, e.g. it should be safe to call multiple times
    without mis-configuring the field.
    """
    class_validators_ = self.class_validators.values()
    if not self.sub_fields or self.shape == SHAPE_GENERIC:
        get_validators = getattr(self.type_, "__get_validators__", None)
        v_funcs = (
            *[v.func for v in class_validators_ if v.each_item and v.pre],
            *(
                get_validators()
                if get_validators
                else list(find_validators(self.type_, self.model_config))
            ),
            *[v.func for v in class_validators_ if v.each_item and not v.pre],
        )
        self.validators = prep_validators(v_funcs)

    self.pre_validators = []
    self.post_validators = []

    if self.field_info and self.field_info.const:
        self.post_validators.append(make_generic_validator(constant_validator))

    if class_validators_:
        self.pre_validators += prep_validators(
            v.func for v in class_validators_ if not v.each_item and v.pre
        )
        self.post_validators = prep_validators(
            v.func for v in class_validators_ if not v.each_item and not v.pre
        )

    if self.parse_json:
        self.pre_validators.append(make_generic_validator(validate_json))

    self.pre_validators = self.pre_validators or None
    self.post_validators = self.post_validators or None