apcore-cli 0.8.0

Command-line interface for apcore modules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
// apcore-cli — Configuration resolver.
// Protocol spec: FE-07 (ConfigResolver, 4-tier precedence)

use std::collections::HashMap;
use std::path::PathBuf;

use tracing::warn;

// ---------------------------------------------------------------------------
// ConfigResolver
// ---------------------------------------------------------------------------

/// Resolved configuration following 4-tier precedence:
///
/// 1. CLI flags   — highest priority
/// 2. Environment variables
/// 3. Config file (YAML, dot-flattened keys)
/// 4. Built-in defaults — lowest priority
pub struct ConfigResolver {
    /// CLI flags map (flag name → value or None if not provided).
    pub cli_flags: HashMap<String, Option<String>>,

    /// Flattened key → value map loaded from the config file.
    /// `None` if the file was not found or could not be parsed.
    pub config_file: Option<HashMap<String, String>>,

    /// Cached parsed YAML root, loaded once at construction. Used by
    /// `resolve_object` so it doesn't re-read+re-parse the file on every
    /// call. `None` when the file is absent, unreadable, or malformed.
    config_yaml: Option<serde_yaml_ng::Value>,

    /// Path to the config file that was loaded (or attempted).
    #[allow(dead_code)]
    config_path: Option<PathBuf>,

    /// Built-in default values.
    pub defaults: HashMap<&'static str, &'static str>,
}

impl ConfigResolver {
    /// Default configuration values.
    ///
    /// Audit D9 (config cleanup, v0.6.x): the entries `sandbox.enabled`,
    /// `cli.auto_approve`, `cli.stdin_buffer_limit`, and the four
    /// `apcore-cli.*` namespace aliases were removed because no production
    /// code path reads them via `resolve()`. Sandbox is configured via the
    /// `--sandbox` CLI flag, auto-approve via `--yes`, the stdin buffer is
    /// hard-coded, and namespace aliases are registered separately by
    /// `apcore`'s Config Bus when the parent crate calls
    /// `apcore::Config::register_namespace`. The cross-key file-lookup
    /// mechanism (`alternate_key`) still works regardless — it does not
    /// depend on these DEFAULTS entries.
    pub const DEFAULTS: &'static [(&'static str, &'static str)] = &[
        ("extensions.root", "./extensions"),
        ("logging.level", "WARNING"),
        ("cli.help_text_max_length", "1000"),
        // FE-11 (v0.6.0)
        ("cli.approval_timeout", "60"),
        ("cli.strategy", "standard"),
        ("cli.group_depth", "1"),
        // Exposure filtering (FE-12)
        ("expose.mode", "all"),
        ("expose.include", "[]"),
        ("expose.exclude", "[]"),
    ];

    /// Namespace key → legacy key mapping for backward compatibility.
    const NAMESPACE_MAP: &'static [(&'static str, &'static str)] = &[
        ("apcore-cli.stdin_buffer_limit", "cli.stdin_buffer_limit"),
        ("apcore-cli.auto_approve", "cli.auto_approve"),
        (
            "apcore-cli.help_text_max_length",
            "cli.help_text_max_length",
        ),
        ("apcore-cli.logging_level", "logging.level"),
    ];

    /// Create a new `ConfigResolver`.
    ///
    /// # Arguments
    /// * `cli_flags`   — CLI flag overrides (e.g. `--extensions-dir → /path`)
    /// * `config_path` — Optional explicit path to `apcore.yaml`
    pub fn new(
        cli_flags: Option<HashMap<String, Option<String>>>,
        config_path: Option<PathBuf>,
    ) -> Self {
        let defaults = Self::DEFAULTS.iter().copied().collect();
        // Parse the config file once; derive both the flat map and the raw
        // Value from the single parse result to avoid reading the file twice.
        let (config_file, config_yaml) = match config_path.as_ref() {
            None => (None, None),
            Some(path) => Self::load_config_both(path),
        };

        Self {
            cli_flags: cli_flags.unwrap_or_default(),
            config_file,
            config_yaml,
            config_path,
            defaults,
        }
    }

    /// Resolve a configuration value using 4-tier precedence.
    ///
    /// # Arguments
    /// * `key`       — dot-separated config key (e.g. `"extensions.root"`)
    /// * `cli_flag`  — optional CLI flag name to check in `_cli_flags`
    /// * `env_var`   — optional environment variable name
    ///
    /// Returns `None` when the key is not present in any tier.
    pub fn resolve(
        &self,
        key: &str,
        cli_flag: Option<&str>,
        env_var: Option<&str>,
    ) -> Option<String> {
        // Tier 1: CLI flag — present and value is Some(non-None string).
        if let Some(flag) = cli_flag {
            if let Some(Some(value)) = self.cli_flags.get(flag) {
                return Some(value.clone());
            }
        }

        // Tier 2: Environment variable — must be set and non-empty.
        if let Some(var) = env_var {
            if let Ok(env_value) = std::env::var(var) {
                if !env_value.is_empty() {
                    return Some(env_value);
                }
            }
        }

        // Tier 3: Config file — key must be present in the flattened map.
        // Try both namespace and legacy keys for backward compatibility.
        if let Some(ref file_map) = self.config_file {
            if let Some(value) = file_map.get(key) {
                return Some(value.clone());
            }
            // Try alternate key (namespace ↔ legacy)
            if let Some(alt) = Self::alternate_key(key) {
                if let Some(value) = file_map.get(alt) {
                    return Some(value.clone());
                }
            }
        }

        // Tier 4: Built-in defaults.
        self.defaults.get(key).map(|s| s.to_string())
    }

    /// Resolve a non-leaf (object-valued) key from the YAML config file.
    ///
    /// Unlike [`Self::resolve`], which returns a flattened scalar string,
    /// this returns the raw `serde_yaml_ng::Value` living at the requested
    /// dot-path. Used by FE-13 (`apcli`) where the top-level key can be a
    /// bool, a mapping, or absent.
    ///
    /// Only consults the config file (Tier 3) — CLI flags and env vars
    /// carry scalar values only. Returns `None` when the file is absent,
    /// unreadable, malformed, or the key is missing.
    pub fn resolve_object(&self, key: &str) -> Option<serde_yaml_ng::Value> {
        // Walk the cached parsed YAML rather than re-reading + re-parsing on
        // every call (review #16). The cache is populated once in `new()`.
        let root = self.config_yaml.as_ref()?;
        let mut cursor = root;
        for segment in key.split('.') {
            match cursor {
                serde_yaml_ng::Value::Mapping(map) => {
                    cursor = map.get(serde_yaml_ng::Value::String(segment.to_string()))?;
                }
                _ => return None,
            }
        }
        Some(cursor.clone())
    }

    /// Read and parse the config file exactly once, returning both the flat
    /// map (for `resolve`) and the raw Value (for `resolve_object`).
    ///
    /// Avoids the double-read that `load_config_file` + `load_config_yaml`
    /// previously incurred on every `ConfigResolver::new` call.
    fn load_config_both(
        path: &PathBuf,
    ) -> (
        Option<HashMap<String, String>>,
        Option<serde_yaml_ng::Value>,
    ) {
        let content = match std::fs::read_to_string(path) {
            Ok(s) => s,
            Err(e) if e.kind() == std::io::ErrorKind::NotFound => return (None, None),
            Err(e) => {
                warn!(
                    "Configuration file '{}' could not be read: {}",
                    path.display(),
                    e
                );
                return (None, None);
            }
        };

        let parsed: serde_yaml_ng::Value = match serde_yaml_ng::from_str(&content) {
            Ok(v) => v,
            Err(_) => {
                warn!(
                    "Configuration file '{}' is malformed, using defaults.",
                    path.display()
                );
                return (None, None);
            }
        };

        if !matches!(parsed, serde_yaml_ng::Value::Mapping(_)) {
            warn!(
                "Configuration file '{}' is malformed, using defaults.",
                path.display()
            );
            return (None, None);
        }

        let mut flat = HashMap::new();
        Self::flatten_yaml_value(parsed.clone(), "", &mut flat);
        (Some(flat), Some(parsed))
    }

    /// Look up the alternate key (namespace ↔ legacy) for backward compatibility.
    fn alternate_key(key: &str) -> Option<&'static str> {
        for &(ns, legacy) in Self::NAMESPACE_MAP {
            if key == ns {
                return Some(legacy);
            }
            if key == legacy {
                return Some(ns);
            }
        }
        None
    }

    /// Recursively flatten a nested YAML value into dot-separated keys.
    fn flatten_yaml_value(
        value: serde_yaml_ng::Value,
        prefix: &str,
        out: &mut HashMap<String, String>,
    ) {
        match value {
            serde_yaml_ng::Value::Mapping(map) => {
                for (k, v) in map {
                    let key_str = match k {
                        serde_yaml_ng::Value::String(s) => s,
                        other => format!("{other:?}"),
                    };
                    let full_key = if prefix.is_empty() {
                        key_str
                    } else {
                        format!("{prefix}.{key_str}")
                    };
                    Self::flatten_yaml_value(v, &full_key, out);
                }
            }
            serde_yaml_ng::Value::Bool(b) => {
                out.insert(prefix.to_string(), b.to_string());
            }
            serde_yaml_ng::Value::Number(n) => {
                out.insert(prefix.to_string(), n.to_string());
            }
            serde_yaml_ng::Value::String(s) => {
                out.insert(prefix.to_string(), s);
            }
            serde_yaml_ng::Value::Null => {
                out.insert(prefix.to_string(), String::new());
            }
            // Sequences and tagged values are serialised as their debug repr;
            // no spec requirement for nested array flattening.
            serde_yaml_ng::Value::Sequence(_) | serde_yaml_ng::Value::Tagged(_) => {
                out.insert(prefix.to_string(), format!("{value:?}"));
            }
        }
    }

    /// Recursively flatten a nested JSON map into dot-separated keys.
    ///
    /// Example: `{"extensions": {"root": "/path"}}` → `{"extensions.root": "/path"}`
    pub fn flatten_dict(&self, map: serde_json::Value) -> HashMap<String, String> {
        let mut out = HashMap::new();
        Self::flatten_json_value(map, "", &mut out);
        out
    }

    /// Recursively walk a `serde_json::Value` and collect dot-notation keys.
    fn flatten_json_value(
        value: serde_json::Value,
        prefix: &str,
        out: &mut HashMap<String, String>,
    ) {
        match value {
            serde_json::Value::Object(obj) => {
                for (k, v) in obj {
                    let full_key = if prefix.is_empty() {
                        k
                    } else {
                        format!("{prefix}.{k}")
                    };
                    Self::flatten_json_value(v, &full_key, out);
                }
            }
            serde_json::Value::Bool(b) => {
                out.insert(prefix.to_string(), b.to_string());
            }
            serde_json::Value::Number(n) => {
                out.insert(prefix.to_string(), n.to_string());
            }
            serde_json::Value::String(s) => {
                out.insert(prefix.to_string(), s);
            }
            serde_json::Value::Null => {
                out.insert(prefix.to_string(), String::new());
            }
            serde_json::Value::Array(_) => {
                out.insert(prefix.to_string(), value.to_string());
            }
        }
    }
}

// ---------------------------------------------------------------------------
// Unit tests
// ---------------------------------------------------------------------------

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_config_resolver_instantiation() {
        let resolver = ConfigResolver::new(None, None);
        assert!(!resolver.defaults.is_empty());
    }

    #[test]
    fn test_defaults_contains_expected_keys() {
        // Audit D9 (v0.6.x): only keys actually consumed by resolve() at
        // runtime live in DEFAULTS. The deleted keys (sandbox.enabled,
        // cli.auto_approve, cli.stdin_buffer_limit, apcore-cli.* aliases)
        // were dead — they're tested for absence by test_deleted_keys_absent.
        let resolver = ConfigResolver::new(None, None);
        for key in [
            "extensions.root",
            "logging.level",
            "cli.help_text_max_length",
            "cli.approval_timeout",
            "cli.strategy",
            "cli.group_depth",
            "expose.mode",
        ] {
            assert!(
                resolver.defaults.contains_key(key),
                "missing default: {key}"
            );
        }
    }

    #[test]
    fn test_deleted_keys_absent() {
        // Verify the audit D9 cleanup didn't accidentally re-introduce dead keys.
        let resolver = ConfigResolver::new(None, None);
        for key in [
            "sandbox.enabled",
            "cli.auto_approve",
            "cli.stdin_buffer_limit",
            "apcore-cli.stdin_buffer_limit",
            "apcore-cli.auto_approve",
            "apcore-cli.help_text_max_length",
            "apcore-cli.logging_level",
        ] {
            assert!(
                !resolver.defaults.contains_key(key),
                "deleted key reintroduced: {key}"
            );
        }
    }

    #[test]
    fn test_default_logging_level_is_warning() {
        let resolver = ConfigResolver::new(None, None);
        assert_eq!(
            resolver.defaults.get("logging.level"),
            Some(&"WARNING"),
            "logging.level default must be WARNING"
        );
    }

    #[test]
    fn test_fe11_defaults_present() {
        let resolver = ConfigResolver::new(None, None);
        assert_eq!(resolver.defaults.get("cli.approval_timeout"), Some(&"60"));
        assert_eq!(resolver.defaults.get("cli.strategy"), Some(&"standard"));
        assert_eq!(resolver.defaults.get("cli.group_depth"), Some(&"1"));
    }

    #[test]
    fn test_resolve_tier1_cli_flag_wins() {
        let mut flags = HashMap::new();
        flags.insert(
            "--extensions-dir".to_string(),
            Some("/cli-path".to_string()),
        );
        let resolver = ConfigResolver::new(Some(flags), None);
        let result = resolver.resolve(
            "extensions.root",
            Some("--extensions-dir"),
            Some("APCORE_EXTENSIONS_ROOT"),
        );
        assert_eq!(result, Some("/cli-path".to_string()));
    }

    #[test]
    fn test_resolve_tier2_env_var_wins() {
        unsafe { std::env::set_var("APCORE_EXTENSIONS_ROOT_UNIT", "/env-path") };
        let resolver = ConfigResolver::new(None, None);
        let result = resolver.resolve("extensions.root", None, Some("APCORE_EXTENSIONS_ROOT_UNIT"));
        assert_eq!(result, Some("/env-path".to_string()));
        unsafe { std::env::remove_var("APCORE_EXTENSIONS_ROOT_UNIT") };
    }

    #[test]
    fn test_resolve_tier3_config_file_wins() {
        // Requires a temp file; skip in unit tests — covered in integration tests.
        // Just verify the method exists and returns None when no file is loaded.
        let resolver = ConfigResolver::new(None, None);
        // With config_path = None, _config_file is None.
        // The default for "extensions.root" should be returned (tier 4).
        let result = resolver.resolve("extensions.root", None, None);
        assert_eq!(result, Some("./extensions".to_string()));
    }

    #[test]
    fn test_resolve_tier4_default_wins() {
        let resolver = ConfigResolver::new(None, None);
        let result = resolver.resolve("extensions.root", None, None);
        assert_eq!(result, Some("./extensions".to_string()));
    }

    #[test]
    fn test_flatten_dict_nested() {
        let resolver = ConfigResolver::new(None, None);
        let map = serde_json::json!({"extensions": {"root": "/path"}});
        let result = resolver.flatten_dict(map);
        assert_eq!(result.get("extensions.root"), Some(&"/path".to_string()));
    }

    #[test]
    fn test_flatten_dict_deeply_nested() {
        let resolver = ConfigResolver::new(None, None);
        let map = serde_json::json!({"a": {"b": {"c": "deep"}}});
        let result = resolver.flatten_dict(map);
        assert_eq!(result.get("a.b.c"), Some(&"deep".to_string()));
    }

    // ---- Namespace-aware config resolution (apcore >= 0.15.0) ----

    #[test]
    fn test_namespace_alternate_key_map_intact() {
        // Audit D9 (v0.6.x): the apcore-cli.* DEFAULTS entries were removed,
        // but the cross-key NAMESPACE_MAP that powers `alternate_key()` is
        // still authoritative. The map's destinations no longer need to be
        // present in DEFAULTS — file lookup via alternate_key() works
        // independently of the defaults dict.
        for ns_key in [
            "apcore-cli.stdin_buffer_limit",
            "apcore-cli.auto_approve",
            "apcore-cli.help_text_max_length",
            "apcore-cli.logging_level",
        ] {
            assert!(
                ConfigResolver::alternate_key(ns_key).is_some(),
                "alternate_key map must still resolve {ns_key}"
            );
        }
    }

    #[test]
    fn test_alternate_key_namespace_to_legacy() {
        assert_eq!(
            ConfigResolver::alternate_key("apcore-cli.stdin_buffer_limit"),
            Some("cli.stdin_buffer_limit")
        );
        assert_eq!(
            ConfigResolver::alternate_key("apcore-cli.auto_approve"),
            Some("cli.auto_approve")
        );
        assert_eq!(
            ConfigResolver::alternate_key("apcore-cli.logging_level"),
            Some("logging.level")
        );
    }

    #[test]
    fn test_alternate_key_legacy_to_namespace() {
        assert_eq!(
            ConfigResolver::alternate_key("cli.stdin_buffer_limit"),
            Some("apcore-cli.stdin_buffer_limit")
        );
        assert_eq!(
            ConfigResolver::alternate_key("cli.auto_approve"),
            Some("apcore-cli.auto_approve")
        );
        assert_eq!(
            ConfigResolver::alternate_key("logging.level"),
            Some("apcore-cli.logging_level")
        );
    }

    #[test]
    fn test_alternate_key_unknown_returns_none() {
        assert_eq!(ConfigResolver::alternate_key("unknown.key"), None);
        assert_eq!(ConfigResolver::alternate_key("extensions.root"), None);
    }

    #[test]
    fn test_resolve_namespace_key_from_legacy_file() {
        // Simulate a config file with legacy "cli.stdin_buffer_limit" key
        let mut file_map = HashMap::new();
        file_map.insert("cli.stdin_buffer_limit".to_string(), "5242880".to_string());
        let resolver = ConfigResolver {
            cli_flags: HashMap::new(),
            config_file: Some(file_map),
            config_yaml: None,
            config_path: None,
            defaults: ConfigResolver::DEFAULTS.iter().copied().collect(),
        };
        // Querying the namespace key should find the legacy key via fallback
        let result = resolver.resolve("apcore-cli.stdin_buffer_limit", None, None);
        assert_eq!(result, Some("5242880".to_string()));
    }

    #[test]
    fn test_resolve_legacy_key_from_namespace_file() {
        // Simulate a config file with namespace "apcore-cli.auto_approve" key
        let mut file_map = HashMap::new();
        file_map.insert("apcore-cli.auto_approve".to_string(), "true".to_string());
        let resolver = ConfigResolver {
            cli_flags: HashMap::new(),
            config_file: Some(file_map),
            config_yaml: None,
            config_path: None,
            defaults: ConfigResolver::DEFAULTS.iter().copied().collect(),
        };
        // Querying the legacy key should find the namespace key via fallback
        let result = resolver.resolve("cli.auto_approve", None, None);
        assert_eq!(result, Some("true".to_string()));
    }

    // ---- resolve_object (FE-13 non-leaf lookup) ----

    fn write_tmp_yaml(body: &str) -> (tempfile::TempDir, PathBuf) {
        let dir = tempfile::tempdir().unwrap();
        let path = dir.path().join("apcore.yaml");
        std::fs::write(&path, body).unwrap();
        (dir, path)
    }

    #[test]
    fn test_resolve_object_returns_bool_shorthand() {
        let (_dir, path) = write_tmp_yaml("apcli: false\n");
        let resolver = ConfigResolver::new(None, Some(path));
        let v = resolver.resolve_object("apcli").expect("apcli key present");
        assert!(matches!(v, serde_yaml_ng::Value::Bool(false)));
    }

    #[test]
    fn test_resolve_object_returns_mapping() {
        let (_dir, path) =
            write_tmp_yaml("apcli:\n  mode: include\n  include:\n    - list\n    - describe\n");
        let resolver = ConfigResolver::new(None, Some(path));
        let v = resolver.resolve_object("apcli").expect("apcli key present");
        let map = match v {
            serde_yaml_ng::Value::Mapping(m) => m,
            _ => panic!("expected mapping"),
        };
        let mode = map
            .get(serde_yaml_ng::Value::String("mode".to_string()))
            .unwrap();
        assert_eq!(mode.as_str(), Some("include"));
    }

    #[test]
    fn test_resolve_object_missing_key_returns_none() {
        let (_dir, path) = write_tmp_yaml("other: 42\n");
        let resolver = ConfigResolver::new(None, Some(path));
        assert!(resolver.resolve_object("apcli").is_none());
    }

    #[test]
    fn test_resolve_object_no_config_file_returns_none() {
        let resolver = ConfigResolver::new(None, None);
        assert!(resolver.resolve_object("apcli").is_none());
    }

    #[test]
    fn test_resolve_object_malformed_yaml_returns_none() {
        let (_dir, path) = write_tmp_yaml("apcli: {unclosed\n");
        let resolver = ConfigResolver::new(None, Some(path));
        assert!(resolver.resolve_object("apcli").is_none());
    }

    #[test]
    fn test_direct_key_takes_precedence_over_alternate() {
        let mut file_map = HashMap::new();
        file_map.insert("cli.help_text_max_length".to_string(), "500".to_string());
        file_map.insert(
            "apcore-cli.help_text_max_length".to_string(),
            "2000".to_string(),
        );
        let resolver = ConfigResolver {
            cli_flags: HashMap::new(),
            config_file: Some(file_map),
            config_yaml: None,
            config_path: None,
            defaults: ConfigResolver::DEFAULTS.iter().copied().collect(),
        };
        assert_eq!(
            resolver.resolve("cli.help_text_max_length", None, None),
            Some("500".to_string())
        );
        assert_eq!(
            resolver.resolve("apcore-cli.help_text_max_length", None, None),
            Some("2000".to_string())
        );
    }
}