Skip to content
A type system for dynamic values in Go applications
Branch: master
Clone or download
apparentlymart cty/convert: Avoid deep recursion when object-to-map unification fails
Due to some over-zealous copying from an earlier function, there was a
codepath in unifyObjectTypesToMap which would recursively call itself with
exactly the same arguments, leading to infinite recursion.

A comment here suggested that this codepath should be unreachable, but
we've seen this be reached at least once (sadly, I was unable to reproduce
it in such a way to let me write a test for it) and so if we hit that
codepath we'll prefer to indicate that no conversion is possible rather
than potentially causing a stack overflow.

With this panic fixed, hopefully if this weird situation is found again in
future it'll be easier to collect information about what situation led to
it, since the end-user that receives it will get a better contextual
error.
Latest commit fd76348 Mar 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cty cty/convert: Avoid deep recursion when object-to-map unification fails Mar 20, 2019
docs
.travis.sh
.travis.yml
LICENSE
README.md
go.mod Get ready to be a Go module Aug 15, 2018
go.sum

README.md

cty

cty (pronounced "see-tie") is a dynamic type system for applications written in Go that need to represent user-supplied values without losing type information. The primary intended use is for implementing configuration languages, but other uses may be possible too.

One could think of cty as being the reflection API for a language that doesn't exist, or that doesn't exist yet. It provides a set of value types and an API for working with values of that type.

Fundamentally what cty provides is equivalent to an interface{} with some dynamic type information attached, but cty encapsulates this to ensure that invariants are preserved and to provide a more convenient API.

As well as primitive types, basic collection types (lists, maps and sets) and structural types (object, tuple), the cty type and value system has some additional, optional features that may be useful to certain applications:

  • Representation of "unknown" values, which serve as a typed placeholder for a value that has yet to be determined. This can be a useful building-block for a type checker. Unknown values support all of the same operations as known values of their type, but the result will often itself be unknown.

  • Representation of values whose types aren't even known yet. This can represent, for example, the result of a JSON-decoding function before the JSON data is known.

Along with the type system itself, a number of utility packages are provided that build on the basics to help integrate cty into calling applications. For example, cty values can be automatically converted to other types, converted to and from native Go data structures, or serialized as JSON.

For more details, see the following documentation:


License

Copyright 2017 Martin Atkins

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.