# Type error from Q chk

**URL:** https://forum.kx.com/t/type-error-from-q-chk/13547
**Category:** Community Support
**Tags:** kdb-and-q, imported
**Created:** [March 16, 2023, 12:00am UTC](https://forum.kx.com/t/type-error-from-q-chk/13547 "2023-03-16T00:00:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![renbright](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@renbright](https://forum.kx.com/u/renbright)
#### Post date: [March 16, 2023, 12:00am UTC](https://forum.kx.com/t/type-error-from-q-chk/13547/1 "2023-03-16T00:00:00Z")

</div>

[https://learninghub.kx.com/forums/topic/type-error-from-q-chk](https://learninghub.kx.com/forums/topic/type-error-from-q-chk)

Does anyone kwon how to solve/fix type error from .Q.chk? how to check which files could have issue?

&nbsp;

Thanks

---

<div class="post-metadata">

### Author: ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)
#### Post date: [March 16, 2023, 12:00am UTC](https://forum.kx.com/t/type-error-from-q-chk/13547/2 "2023-03-16T00:00:00Z")

</div>

There’s a thread with some info on stackoverflow:

[https://stackoverflow.com/questions/67272148/q-chk-gives-a-type-error-when-ran-on-a-hdb-how-can-i-debug-or-what-should-i](https://stackoverflow.com/questions/67272148/q-chk-gives-a-type-error-when-ran-on-a-hdb-how-can-i-debug-or-what-should-i")

&nbsp;

Running `strace -p pid` may help show where `.Q.chk` is falling down.

&nbsp;

This is a basic outline of a helper function I created before to debug a `part` error when trying to load a HDB.

It may be a good starting point for finding the root cause issue for you too.

```
//[https://code.kx.com/q/ref/system/#capture-stderr-output](https://code.kx.com/q/ref/system/#capture-stderr-output")q)tmp:first system"mktemp" 
q){d:1_string x;{y:string y;(y;"D"$y),{r:system x;show last r;$[1~"J"$last r;(1b;-1_r;"");(0b;();-1_r)]} "ls ",x,"/",y," > ",tmp," 2>&1;echo $? >> ",tmp,";cat ",tmp}[d] each key x} `:badHDB 
q)tab:flip `part`date`osError`files`error!flip {d:1_string x;{y:string y;(y;"D"$y),{r:system x;$[0~"J"$last r;(0b;-1_r;"");(1b;();first r)]} "ls ",x,"/",y," > ",tmp," 2>&1;echo $? >> ",tmp,";cat ",tmp}[d] each key x} `:badHDB
```

The resulting table:

```
part date osError files error 
----------------------------------------------------------------------------------------------------------- 
"2001.01.01" 2001.01.01 0 ,"tab1" "" 
"2001.01.01" 0 ,"tab2" "" 
"2002.01.01" 2002.01.01 1 () "ls: cannot open directory 'badHDB/2002.01.01': Permission denied"
```

For a larger HDB filter down to partitions with issues:

```
select from tab where or[null date;osError]
```

&nbsp;

---

<div class="post-metadata">

### Author: ![lkerr2](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lkerr2/32/57_2.png) [@lkerr2](https://forum.kx.com/u/lkerr2)
#### Post date: [March 16, 2023, 12:00am UTC](https://forum.kx.com/t/type-error-from-q-chk/13547/3 "2023-03-16T00:00:00Z")

</div>

As a simple starting point before investigating the data, type errors in Q suggest that you have provided the wrong datatype to a function. In the case of **.Q.chk** make sure you’re passing in a filepath as per the [documentation](https://code.kx.com/q/ref/dotq/#chk-fill-hdb") which is a **symbol** type. If you could share the line of code you’re calling the **.Q.chk** in and the argument you’re providing, as well as an **ls** on the directory you’re performing the check on, that would help in isolating the problem. An example call of **.Q.chk** is:

&nbsp;

.Q.chk[`:/path/to/dir]

&nbsp;

**N.B.** You will get a type error if you call **.Q.chk** with a string:

&nbsp;

q).Q.chk[“/path/to/dir”]

'type [0]

.Q.chk[“/path/to/dir”]

&nbsp;

Hope this helps!
