1919 USER_ROLE_DEFAULT ,
2020 LLM_MAX_CONCURRENT_REQUESTS ,
2121 LLM_MAX_KEEP_ALIVE_CONNECTIONS ,
22- MAXIMUM_LOG_LENGTH ,
22+ DEFAULT_MAXIMUM_LOG_MIB
2323)
24- from logdetective .utils import check_csgrep
24+ from logdetective .utils import check_csgrep , mib_to_bytes
2525
2626
2727class BuildLogFile (BaseModel ):
@@ -33,7 +33,10 @@ class BuildLogFile(BaseModel):
3333 max_length = 255 ,
3434 pattern = r"^[a-zA-Z0-9._\-\/ ]+$"
3535 )
36- content : str = Field (max_length = MAXIMUM_LOG_LENGTH )
36+ content : str = Field (
37+ description = "Log file content as a string. By default, request size "
38+ "is limited to 300 MiB. This can affect what kind of logs can be submitted."
39+ )
3740
3841
3942class BuildLogRequest (BaseModel ):
@@ -257,16 +260,15 @@ class GitLabInstanceConfig(BaseModel): # pylint: disable=too-many-instance-attr
257260
258261 timeout : float = 5.0
259262
260- # Maximum size of artifacts.zip in MiB. (default: 300 MiB)
261- max_artifact_size : int = 300 * 1024 * 1024
263+ # Maximum size of artifacts.zip (default: 300 MiB)
264+ # In config, the unit is in MiB, but this max_artifact_size attribute will be in bytes
265+ max_artifact_size : int = mib_to_bytes (DEFAULT_MAXIMUM_LOG_MIB )
262266
263267 @field_validator ("max_artifact_size" , mode = "before" )
264268 @classmethod
265269 def megabytes_to_bytes (cls , v : Any ):
266270 """Convert max_artifact_size from megabytes to bytes."""
267- if isinstance (v , int ):
268- return v * 1024 * 1024
269- return 300 * 1024 * 1024
271+ return mib_to_bytes (v if isinstance (v , int ) else DEFAULT_MAXIMUM_LOG_MIB )
270272
271273
272274class GitLabConfig (BaseModel ):
@@ -302,15 +304,15 @@ class KojiConfig(BaseModel):
302304
303305 instances : Dict [str , KojiInstanceConfig ] = {}
304306 analysis_timeout : int = 15
305- max_artifact_size : int = 300 * 1024 * 1024
307+
308+ # in yaml config, this is given in MiB, but we use bytes in code (same as gitlab)
309+ max_artifact_size : int = mib_to_bytes (DEFAULT_MAXIMUM_LOG_MIB )
306310
307311 @field_validator ("max_artifact_size" , mode = "before" )
308312 @classmethod
309313 def megabytes_to_bytes (cls , v : Any ):
310314 """Convert max_artifact_size from megabytes to bytes."""
311- if isinstance (v , int ):
312- return v * 1024 * 1024
313- return 300 * 1024 * 1024
315+ return mib_to_bytes (v if isinstance (v , int ) else DEFAULT_MAXIMUM_LOG_MIB )
314316
315317 @model_validator (mode = "before" )
316318 @classmethod
@@ -347,6 +349,14 @@ class GeneralConfig(BaseModel):
347349 collect_emojis_interval : int = 60 * 60 # seconds
348350 top_k_snippets : int = 0
349351 report_certainty : bool = False
352+ # max_artifact_size in config.yml is in MiBs, here (GeneralConfig class) is in bytes
353+ max_artifact_size : int = mib_to_bytes (DEFAULT_MAXIMUM_LOG_MIB )
354+
355+ @field_validator ("max_artifact_size" , mode = "before" )
356+ @classmethod
357+ def megabytes_to_bytes (cls , v : Any ):
358+ """Convert max_artifact_size from megabytes to bytes."""
359+ return mib_to_bytes (v if isinstance (v , int ) else DEFAULT_MAXIMUM_LOG_MIB )
350360
351361
352362class Config (BaseModel ):
0 commit comments