Pure gold.
Indeed, Fire Bolt can hit creatures or objects, but Ray of Frost can only hit creatures. Why? And neither can target a location. Again, why? It makes no sense. I assume there is some kind of game balance reason for it, but I'll be darned if I can figure out what it is.
I say if you want to cast a Ray of Frost at a location that you think contains an invisible creature, go for it! If you're wrong it will hit the wall behind that location and frost the wall. Same as if you fired an arrow (except the arrow would do piercing damage instead of cold damage to the wall).
So can anyone tell me why Ray of Frost shouldn't be able to target an object? Or why any cantrip shouldn't target a location?
Making an object cold is usually not enough to "damage" it, at least not at the same rate as a body/creature (lots of exceptions, i know), and usually empty spaces aren't going to be affected by cantrips that can only be targeted at creature and objects. Fire bolt on the other hand can be used to ignite materials. Not having it capable of targeting objects would make that part of the spell pretty much unusable. Expecially if we consider that WotC might very well have truly meant "not a valid target = target not affected but spell still cast". Btw, Ray of Frost does not require vision (as in, you do not have to see it, still it can't be behind total cover) of a target. And if the target is not hiding or has used some other form of magic other than just invisibility to conceal his presence, you know where it is. No need to guess. If it has, you have completely lost his position. You know where you think it was last, but even then, your character is uncertain. Remember, turns are a game simplification. And combat movement is going to be quite more complex than what we are simulating at the table.
I also spent some time thinking about at some different implications of the targeting system that are not apparent... what happens if someone casts a Disintegrate to a target behind a wall of force? Nothing. The disintegrate impact the wall of force and stops there, the wall of force still standing. Same to the shield put in between the caster and the target at the last minute due to feats. The specified target was not hit, there's no effect. (exceptions - area of effect spells on highly obscured cover etc...) (shield example extrapolated from old sage advice interaction between Shield Master and Disintegrate). This to make it simple to also justify how the missed rolls cannot really cause unwanted mayhem if a fight breaks out in a village, for example.
So, i'm quite convinced that, in the end, it could be "target is not a valid one OR a valid one but not the specified one -> Spell is cast, no effect, unless exceptions"
By this "rule", you COULD target a location of an invisible, hidden enemy that's right in front of you. You would be targetting a location, not the creature. Even if we assume that you , when firing at an invisible non hidden target you are actually pointing at a location, and not at the creature... you would know at least SOMETHING about that creature "it has just left the footprint there! Shoot the feet!" or "it's breathing, the head is there!", while the hidden invisible creature you are totally guessing out. You could try to estimate a "range" at which the spell would have effect on the skin of the target, at least having some information (invisible non hidden, you roll at disadvantage) , the other would be absolute, total, improbable not even one in a million and one chance. (hit even a little bit inside, the spell has no effect). I would probably allow the second as an Hail Mary sort of situation. For dramatic effect, more than anything.
Obviously, all imho, and totally nothing more than an interpretation, with some looking at the rules.
