You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "rambleraptor (via GitHub)" <gi...@apache.org> on 2025/06/29 00:00:41 UTC

[I] Literals should raise a more friendly error message [iceberg-python]

rambleraptor opened a new issue, #2160:
URL: https://github.com/apache/iceberg-python/issues/2160

   We should find a way to make sure that incorrect Literals raise a friendlier error message than the standard Pydantic error message. Pydantic might be able to do this for us.
   
   _Originally posted by @jayceslesar in https://github.com/apache/iceberg-python/pull/2154#discussion_r2173331913_
               


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Literals should raise a more friendly error message [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #2160: Literals should raise a more friendly error message
URL: https://github.com/apache/iceberg-python/issues/2160


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Literals should raise a more friendly error message [iceberg-python]

Posted by "jayceslesar (via GitHub)" <gi...@apache.org>.
jayceslesar commented on issue #2160:
URL: https://github.com/apache/iceberg-python/issues/2160#issuecomment-3016761060

   Nice, yeah looks like we can do something like 
   ```py
   from typing import Any, Literal
   
   from pydantic import BaseModel, Field, field_validator
   
   
   class MyModel(BaseModel):
       my_literal: Literal[1] = Field(alias="my-literal")
   
       @field_validator("my_literal", mode="before")
       def validate_my_literal(cls, v: Any) -> int:
           """Validate that my_literal is 1 for MyModel."""
           if v != 1:
               raise ValueError(f"MyModel requires my-literal to be 1, got {v}")
           return v
   
   MyModel(**{"my-literal": 2})
   ```
   
   Which raises 
   ```
   pydantic_core._pydantic_core.ValidationError: 1 validation error for MyModel
   my-literal
     Value error, MyModel requires my-literal to be 1, got 2 [type=value_error, input_value=2, input_type=int]
       For further information visit https://errors.pydantic.dev/2.11/v/value_error
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Literals should raise a more friendly error message [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #2160:
URL: https://github.com/apache/iceberg-python/issues/2160#issuecomment-3697891943

   This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Literals should raise a more friendly error message [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #2160:
URL: https://github.com/apache/iceberg-python/issues/2160#issuecomment-3747127977

   This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org